Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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
You can’t perform that action at this time.