public ActionResult Index() { var users = _usersRepository.Get(); ViewBag.LoggedInUserIsSuperAdmin = HttpContext.User.IsInRole(RoleConstants.SuperAdminRole); return(View(users)); }
public async Task <ActionResult> Index(InstallViewModel model) { // Self registration is active as long as the administrator was not created yet var roleExists = await _rolesRepository.RoleExists(RoleConstants.SuperAdminRole); if (roleExists) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { var user = _usersRepository.Get().SingleOrDefault(x => x.Email == model.Email); if (user == null) { user = new ApplicationUser { Email = model.Email, UserName = model.Email, }; var userResult = await UserManager.CreateAsync(user, model.Password); if (userResult.Succeeded) { await SendAdminEmailConfirmation(user.Id, "Confirm your account"); ViewBag.Message = ViewResource.RegisterConfirmationMessage; return(View("Info")); } else { AddErrors(userResult); } } else { await SendAdminEmailConfirmation(user.Id, "Confirm your account"); ViewBag.Message = ViewResource.RegisterConfirmationMessage; return(View("Info")); } } // If we got this far, something failed, redisplay form return(View(model)); }