private async Task <string> Authenticate(UserAccountModel body) { DynamicParameters userName_params = new DynamicParameters(); userName_params.Add("@userName", body.userName); string claimsString = $"SELECT [id], [role] FROM [User] WHERE [userName] = @userName"; var claimsList = await _db.SelectAsync <UserAccountModel, dynamic>(claimsString, userName_params); if (claimsList.Count < 1) { IActionResult actionResult = customActionResult.UnavailableForLegalReasons( "Claims unavailable for the current user. Authorization denided." ); StatusCode(StatusCodes.Status451UnavailableForLegalReasons, actionResult); return(null); } else { _user.id = claimsList[0].id; _user.role = claimsList[0].role; return(_authManager.GenerateJSONWebToken(body, _user)); } }