question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose UserManager<T>.GetChangeEmailTokenPurpose()

See original GitHub issue

UserManager In 2.1 exposed the “purpose” constants, eg. ConfirmEmailTokenPurpose.

We relied on this in order to use userManager.VerifyUserTokenAsync().

Now those constants are gone, and there is a GetChangeEmailTokenPurpose() method in its place, which is protected.

Please make it public, otherwise the verify function is unusable.

(Subclassing just adds an unnecessary mess as this class already conceals a lot of complexity and should be usable as is.)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
HaoKcommented, Jul 26, 2019

Something for the backlog / future @blowdart

0reactions
lonix1commented, Jul 26, 2019

Thanks for looking into this.

I’ve opted to subclass instead, to avoid magic strings (as shown by this issue, it’s a bad idea to rely on magic strings 😄).

For anyone else migrating code to 2.2, note that if you subclass, it’s important not to register the subclass with the container, but to replace the default during init:

services
.AddIdentityCore<User>()
.AddUserManager<MyUserManager<User>>()    // <--- the magic

And then it’s as easy as this:

public async Task<bool> ValidateEmailChangeToken(TUser user, string newEmail, string token) {
  return await VerifyUserTokenAsync(
    user,
    Options.Tokens.ChangeEmailTokenProvider,
    GetChangeEmailTokenPurpose(newEmail),
    token
  );
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expose UserManager<T>.GetChangeEmailTokenPurpose()
UserManager In 2.1 exposed the "purpose" constants, eg. ConfirmEmailTokenPurpose. We relied on this in order to use userManager.
Read more >
UserManager<TUser>.GetChangeEmailTokenPurpose ...
Generates the token purpose used to change email.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found