Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor issue with authentication generator if service name is not "user" #3412

Open
mrobst opened this issue Jan 29, 2024 · 0 comments
Open

Comments

@mrobst
Copy link
Contributor

mrobst commented Jan 29, 2024

Minor issue - running the feathers authentication generator appears to scaffold an authentication service which assumes the service is always called user.

To reproduce the error generate authentication per the documenatation:

? Which authentication methods do you want to use? Other methods and providers can be added at any time. Email + Password
? What is your authentication service name? admin
? What path should the service be registered on? admins
? What database is the service using? SQL
? Which schema definition format do you want to use? Schemas allow to type, validate, secure and populate data TypeBox
(recommended)```


The file admins.schema.ts will be generated with the following minor errors:

```export const adminQueryResolver = resolve<AdminQuery, HookContext<AdminService>>({
  // If there is a user (e.g. with authentication), they are only allowed to see their own data
  id: async (value, user, context) => {
    if (context.params.user) {    <-- user does not exist
      return context.params.user.id   <-- user does not exist
    }

    return value
  }
})```

Replacing the context.params.user with context.params.admin in two places resolves the issue. 

Perhaps the authentication generator should read the service schema id dynamically to improve this? 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant