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

External Auth Strategy for Admin Gives an Error of User <not found> #1489

Closed
fahadaleem opened this issue Mar 25, 2022 · 3 comments · Fixed by #2622
Closed

External Auth Strategy for Admin Gives an Error of User <not found> #1489

fahadaleem opened this issue Mar 25, 2022 · 3 comments · Fixed by #2622
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@fahadaleem
Copy link

fahadaleem commented Mar 25, 2022

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Clone this repo
  2. Perform the mutation on authentication with Input strategy and externalIdentifier
  3. Now, open http://localhost:3000/admin/
  4. See error No User with the id '' could be found

Expected behavior
Admin user should be logged in with the custom auth strategy, or with the externalIdentifier that I sent it from my client site.

Environment (please complete the following information):

  • @vendure/core version:
  • Nodejs version
  • Database (postgres):

Additional context
I am trying to implement a custom auth for admin, for testing purposes I have just taken auth strategy and external identifier as an input in authenticate mutation and then allow it to check if there is admin available with these inputs, if the user exists then return the user else create a new one as mentioned on the vendure documentation. But it is showing an error while logging.

1

Here is the database tables snapshots
Administrator Table
administrator table
administrator table1

Users Table
users table

Authentication method table
auth method table1
auth method table2

@fahadaleem fahadaleem added the type: bug 🐛 Something isn't working label Mar 25, 2022
@michaelbromley
Copy link
Member

Hi, could you include all the info you shared in the slack chat - the code for your auth strategy and then the resulting rows in your db tables?

@fahadaleem
Copy link
Author

Hi, I have added the screenshots of the tables.

@michaelbromley
Copy link
Member

Thanks for taking the time to create the repo. The problem is that the identifier field should match the email address:

return this.externalAuthenticationService.createAdministratorAndUser(ctx, {
  strategy: data.strategy,
  externalIdentifier: data.externalIdentifier,
-  identifier: "goldadmin",
+  identifier: "goldn@admin.com",
  emailAddress: "goldn@admin.com",
  firstName: "goldn",
  lastName: "admin",
  roles: [merchantRole],
});

Try that and let me know if it works for you.

michaelbromley added a commit that referenced this issue Jan 23, 2024
Relates to #1489. The previous resolution method would fail when using a
non-native auth strategy that was not based on an email identifier.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants