private async Task <string> SetUserRole(AppUser user) { if (user != null) { IList <string> roles = await accountAdapter.GetUserRoles(user.Id).ConfigureAwait(false); return(roles.Contains("admin") ? "admin" : "user"); } return(null); }
public async Task <ActionResult> GetUserRoles(string id) { try { if (id == "null" || id == null) { logger.LogError("User id object sent from client is null"); return(BadRequest("User id object is null")); } return(Ok(await accountAdapter.GetUserRoles(id).ConfigureAwait(false))); } catch (Exception ex) { logger.LogError($"Something went wrong inside GetUserRoles action: {ex.Message}"); return(StatusCode(500, "Internal server error")); } }