-
Notifications
You must be signed in to change notification settings - Fork 645
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
Remove password credential from user when they link an external account #5382
Changes from 1 commit
98547a2
d19f753
9f26b52
8b47b7a
1d79052
3908539
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -401,7 +401,7 @@ public virtual async Task<ActionResult> LinkOrChangeExternalCredential(string re | |
await _authService.CreateSessionAsync(OwinContext, authenticatedUser); | ||
|
||
// Remove the password credential after linking to external account. | ||
var passwordCred = user.Credentials.SingleOrDefault(c => c.IsPassword()); | ||
var passwordCred = user.GetPassword(); | ||
|
||
if (passwordCred != null) | ||
{ | ||
|
@@ -536,7 +536,7 @@ private async Task<AuthenticatedUser> AssociateCredential(AuthenticatedUser user | |
|
||
await _authService.AddCredential(user.User, result.Credential); | ||
|
||
var passwordCredential = user.User.Credentials.SingleOrDefault(c => c.IsPassword()); | ||
var passwordCredential = user.User.GetPassword(); | ||
if (passwordCredential != null) | ||
{ | ||
await _authService.RemoveCredential(user.User, passwordCredential); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want this in the same transaction as AddCredential? Should the APIs support deferring the SaveChangesAsync? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think if removing the password fails, we should still proceed with the request, just leave the credential there--no need to remove a perfectly valid external credential. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably also a problem with @shishirx34's link and replace flow, where I based this code off of. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree it would be much better to have an API for |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: perhaps
GetPasswordCredential
be more appropriate? GetPassword seems like we are getting the password value. Don't care though.