public async Task <IActionResult> Index() { // set up test user Entities.ApplicationUser defaultUser = new Entities.ApplicationUser() { UserName = "******", Email = "*****@*****.**", PhoneNumber = "000-000-0000", }; // set up test Administrators role Entities.ApplicationRole administratorsRole = new Entities.ApplicationRole() { Name = "Administrators" }; Entities.ApplicationUser user = await _userManager.FindByNameAsync(defaultUser.UserName); Entities.ApplicationRole role = await _roleManager.FindByNameAsync(administratorsRole.Name); if (user == null && role == null) { await _userManager.CreateAsync(defaultUser, "Testpassword#1"); await _roleManager.CreateAsync(administratorsRole); await _userManager.AddToRolesAsync(defaultUser, new string[] { administratorsRole.Name }); } return(View()); }
public ApplicationUserViewModel(Entities.ApplicationUser user) { this.UserName = user.UserName; this.FirstName = user.FirstName; this.LastName = user.LastName; this.Id = user.Id; this.IsLockedOut = user.IsLockedOut; }
public async Task <ActionResult> Delete(string username) { Entities.ApplicationUser user = await _userManager.FindByNameAsync(username); await _userManager.DeleteAsync(user); return(RedirectToAction("cp", "home")); }
public UserReportViewModel(Entities.ApplicationUser user) { Id = user.Id; UserName = user.UserName; Roles = string.Join("/", (from r in user.Roles select r.Role.Name)); IsLockedOut = user.IsLockedOut; IsApproved = user.IsApproved; LastLogin = user.LastLoginDate; }
public async Task <ActionResult> SignIn(string username, string password) { Entities.ApplicationUser user = await _userManager.FindByNameAsync(username); if (await _userManager.CheckPasswordAsync(user, password)) { await _signInManager.SignInAsync(user, false); } return(RedirectToAction("index", "home")); }
public EditUserViewModel(Entities.ApplicationUser user, string loggedOnUserName) : this() { this.UserName = user.UserName; this.FirstName = user.FirstName; this.LastName = user.LastName; this.Email = user.Email; this.UserId = user.Id; this.IsLockedOut = user.IsLockedOut; this.IsApproved = user.IsApproved; this.LoggedOnUserName = loggedOnUserName; }
public async Task <ActionResult> RemoveUsersFromRoles(string usernames, string rolenames) { string[] userNames = usernames.Split(", "); string[] roleNames = rolenames.Split(", "); foreach (string userName in userNames) { Entities.ApplicationUser user = await _userManager.FindByNameAsync(userName); await _userManager.RemoveFromRolesAsync(user, roleNames); } return(RedirectToAction("cp", "home")); }
public async Task <ActionResult> Create(string username, string password, string confirm) { if (password == confirm) { Entities.ApplicationUser user = new Entities.ApplicationUser() { UserName = username, Email = "*****@*****.**", PhoneNumber = "999-999-9999", }; await _userManager.CreateAsync(user, password); } return(RedirectToAction("cp", "home")); }
public EnvironmentViewModel(Entities.ApplicationUser user) { this.Environments = new List <String>(); this.SelectedEnvironment = user.PreferredEnvironment; }
public async Task <bool> CheckPasswordAsync(Entities.ApplicationUser user, string password) { return(await this.userManager.CheckPasswordAsync(user, password)); }
public async Task <IdentityResult> CreateUserAsync(Entities.ApplicationUser applicationUser, string password) { IdentityResult identityResult = await this.userManager.CreateAsync(applicationUser, password); return(identityResult); }
public async Task <IdentityResult> AddUserDefaultRoleAsync(Entities.ApplicationUser applicationUser, string userRole) { return(await this.userManager.AddToRoleAsync(applicationUser, userRole)); }