Skip to content

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

Closed

Description

@mrobst

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? 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions