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

IUserAuthenticationTokenStore fails to set token if token already exists #15399

Closed
deanmarcussen opened this issue Feb 26, 2024 · 1 comment
Closed
Labels

Comments

@deanmarcussen
Copy link
Member

deanmarcussen commented Feb 26, 2024

this code

var userToken = GetUserToken(user, loginProvider, name);
if (userToken == null && user is User u)
{
userToken = new UserToken
{
LoginProvider = loginProvider,
Name = name
};
u.UserTokens.Add(userToken);
}
// Encrypt the token.
if (userToken != null)
{
userToken.Value = _dataProtectionProvider.CreateProtector(TokenProtector).Protect(value);
}

looks like it has lots of problems.

Firstly, if the token is found in the UserTokens list, it doesn't reset it.
This assumes that the value is still the same, when if you're storing access tokens or similar, then the value has changed.

Also on Line 701 it protects the token. Which would double /triple etc protect it, if the token already exists.

There is a RemoveAsync method, on the api, but to me, it doesn't make sense that you're forced to check for an existing token, then remove it, then re add it.

@deanmarcussen
Copy link
Member Author

Closing re read the code better, and it would work.

Must have a problem somewhere else

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant