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

Updating customer fails when NativeAuthenticationMethod not configured #1092

Closed
michaelbromley opened this issue Sep 16, 2021 · 0 comments
Closed
Assignees
Labels
type: bug 🐛 Something isn't working @vendure/core

Comments

@michaelbromley
Copy link
Member

Describe the bug
A change in v1.2.1 in response to #1071 prevents updating customers if the NativeAuthenticationMethod is not being used (e.g. when relying solely on an external auth method).

This is because when updating the Customer, if the emailAddress input is present (as is always the case when using the Admin UI), then this method gets called:

async changeNativeIdentifier(ctx: RequestContext, userId: ID, newIdentifier: string) {
const user = await this.getUserById(ctx, userId);
if (!user) {
return;
}
const nativeAuthMethod = user.getNativeAuthenticationMethod();
user.identifier = newIdentifier;
nativeAuthMethod.identifier = newIdentifier;
nativeAuthMethod.identifierChangeToken = null;
nativeAuthMethod.pendingIdentifier = null;
await this.connection
.getRepository(ctx, NativeAuthenticationMethod)
.save(nativeAuthMethod, { reload: false });
await this.connection.getRepository(ctx, User).save(user, { reload: false });
}

The user.getNativeAuthenticationMethod(); call will throw an error if it is not found.

The solution is:

  1. Only invoke that changeNativeIdentifier() method if the email address has changed
  2. Inside the method, use a try-catch block to prevent errors if it ever gets called in a situation with no native auth configured.

Environment (please complete the following information):

  • @vendure/core version: 1.2.1
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 @vendure/core
Projects
None yet
Development

No branches or pull requests

1 participant