private bool CheckPassword(UserEM user, string password) { try { var userHash = ComputeHash(user, password); return(userHash.SequenceEqual(user.PasswordHash)); } catch { return(false); } }
public ClaimsIdentity CreateClaims(UserEM user) { var claims = new List <Claim> { new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()), new Claim(ClaimTypes.Email, user.Email), new Claim(ClaimsIdentity.DefaultNameClaimType, user.UserName), new Claim(ClaimsIdentity.DefaultRoleClaimType, user.Role.Name) }; return(new ClaimsIdentity(claims, "Token", ClaimsIdentity.DefaultNameClaimType, ClaimsIdentity.DefaultRoleClaimType)); }
private byte[] ComputeHash(UserEM user, string password) { return(cryptoService.ComputeHash(cryptoService.Xor(user.GetIdentityBytes(password), user.Salt))); }