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
[FunctionName("GetCurrentUserFunction")] | |
public async Task<IActionResult> Run( | |
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "current/user")]HttpRequestMessage eventData, | |
ILogger logger, | |
[UserToken]UserTokenResult userResult) | |
{ | |
if (userResult.TokenState == TokenState.Valid) | |
{ | |
var user = await _dataProvider.GetUserByUsername(userResult.Username); | |
if (user == null) | |
{ | |
return new NotFoundResult(); | |
} | |
return new OkObjectResult(user); | |
} | |
else if (userResult.TokenState == TokenState.Empty) | |
{ | |
return new BadRequestResult(); | |
} | |
else | |
{ | |
return new UnauthorizedResult(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment