Created
December 28, 2019 23:20
-
-
Save xximjasonxx/89b3f903dbf79ae514b2d21878bdb40e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public UserTokenValueProvider(string userToken, string issuerToken, IReadTokenService readTokenService) | |
{ | |
_userToken = userToken; | |
_issuerToken = issuerToken; | |
_readTokenService = readTokenService; | |
} | |
public async Task<object> GetValueAsync() | |
{ | |
try | |
{ | |
var readResult = _readTokenService.ReadToken(_userToken); | |
return new UserTokenResult { Username = readResult.Username, TokenState = TokenState.Valid }; | |
} | |
catch (ArgumentNullException) | |
{ | |
// token not provided | |
return new UserTokenResult { TokenState = TokenState.Empty }; | |
} | |
catch | |
{ | |
// token was bad | |
return new UserTokenResult { TokenState = TokenState.Invalid }; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment