public async Task<IActionResult> Index(SearchViewModel model) { // Get the user and the UserType claim var user = await _userManager.FindByEmailAsync(model.Email); var claims = await _userManager.GetClaimsAsync(user); if (claims.Count <= 0) { model.TenantAdmin = false; return View("MakeUserTenantAdmin", model); } var claimValue = claims.FirstOrDefault(c => c.Type.Equals("UserType")).Value; if (!claimValue.Equals("TenantAdmin")) { model.TenantAdmin = false; } return View("MakeUserTenantAdmin", model); }
public async Task<IActionResult> MakeUserTenantAdmin(SearchViewModel model, bool diff) { var user = await _userManager.FindByEmailAsync(model.Email); if (model.TenantAdmin) { var result = await _userManager.AddClaimAsync(user, new Claim("UserType", "TenantAdmin")); if(result.Succeeded) { ViewData["result"] = "Successfully approved user"; return View(); } else { ViewData["result"] = "Successfully approved user"; return Redirect("Error"); } } return RedirectToAction("Index"); }
public IActionResult MakeUserTenantAdmin(SearchViewModel model) { return View(model); }