public async Task UpdateAsync(tmIdentityUser user) { user.TimeStamp = DateTime.UtcNow; this._dbContext.Users.Attach(user); this._dbContext.Entry(user).State = EntityState.Modified; await this._dbContext.SaveChangesAsync(); }
public async Task CreateAsync(tmIdentityUser user) { user.Id = Guid.NewGuid().ToString(); user.DateUTCCreated = DateTime.UtcNow; user.TimeStamp = DateTime.UtcNow; this._dbContext.Users.Add(user); this._dbContext.Configuration.ValidateOnSaveEnabled = false; if (await this._dbContext.SaveChangesAsync() == 0) { throw new Exception("Error creating new user"); } }
public async Task <ClaimsIdentity> CreateIdentityAsync(tmIdentityUser user, string authenticationType) { user = await this.FindByNameAsync(user.UserName); if (user != null) { List <Claim> claims = new List <Claim> { new Claim(ClaimTypes.Name, user.UserName), new Claim(ClaimTypes.NameIdentifier, user.Id), new Claim(ClaimTypes.AuthenticationMethod, authenticationType) }; return(new System.Security.Claims.ClaimsIdentity(claims, authenticationType)); } return(null); }
public async Task <tmIdentityResult> CreateAsync(string username, string password, string passwordConfirmation) { var user = await UserManager.FindByNameAsync(username); if (user == null) { user = new tmIdentityUser(); user.UserName = username; try { user.PasswordHash = HashingConfig.HashPassword(password); await UserManager.CreateAsync(user); } catch (Exception ex) { return(new tmIdentityResult(ex.Message)); } return(new tmIdentityResult()); } return(new tmIdentityResult("Username already registered")); }
public async Task SetPasswordHashAsync(tmIdentityUser user, string passwordHash) { user.PasswordHash = passwordHash; await this.UpdateAsync(user); }
public async Task <bool> HasPasswordAsync(tmIdentityUser user) { user = await this.FindByNameAsync(user.UserName); return(!string.IsNullOrEmpty(user.PasswordHash)); }
public async Task <string> GetPasswordHashAsync(tmIdentityUser user) { user = await this.FindByNameAsync(user.UserName); return(user.PasswordHash); }
public async Task DeleteAsync(tmIdentityUser user) { this._dbContext.Users.Remove(user); await this._dbContext.SaveChangesAsync(); }