Esempio n. 1
0
 private bool CheckPassword(UserEM user, string password)
 {
     try
     {
         var userHash = ComputeHash(user, password);
         return(userHash.SequenceEqual(user.PasswordHash));
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
 private byte[] ComputeHash(UserEM user, string password)
 {
     return(cryptoService.ComputeHash(cryptoService.Xor(user.GetIdentityBytes(password), user.Salt)));
 }