public DomainUser Register(DomainUser model, string password, IAuthenticationManager authenticationManager) { var user = Mapper.Map<User>(model); var result = Uow.UserManager.Create(user, password); if (!result.Succeeded) { return null; } Uow.UserManager.AddToRole(user.Id, "User"); return Mapper.Map<DomainUser>(user); }
public async Task<ClaimsIdentity> GenerateClaimAsync(DomainUser userDomainModel) { var user = Mapper.Map<User>(userDomainModel); var claimsIdentity = await Uow.UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie); return claimsIdentity; }
public async Task<IdentityResult> UpdateUserAsync(int userId, DomainUser model) { var user = Uow.UserManager.FindById(userId); user.FirstName = model.FirstName; user.LastName = model.LastName; user.Birthday = model.Birthday; var result = await Uow.UserManager.UpdateAsync(user); return result; }
private async Task SignInAsync(DomainUser user, bool isPersistent) { AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie); AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, await UserService.GenerateClaimAsync(user)); }