Esempio n. 1
0
        public async Task <int> ResetPassword(string password, string token)
        {
            ClaimsPrincipal claims = _tokenManager.Decode(token, Encoding.ASCII.GetBytes(_configuration.GetSection("Jwt")["ResetPasswordSecretKey"]));
            var             claim  = claims.Claims.ToList();
            string          email  = claim[1].Value;
            Account         user   = await _repository.Get(email);

            return(await _repository.ResetPassword(user, BCrypt.Net.BCrypt.HashPassword(password)));
        }
Esempio n. 2
0
 public async Task <int> ResetPassword(string password, string token)
 {
     try
     {
         ClaimsPrincipal claims = _tokenManager.Decode(token);
         var             claim  = claims.Claims.ToList();
         return(await _repository.ResetPassword(claim[0].Value, password));
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Esempio n. 3
0
        public async Task <int> ResetPassword(string password, string token)
        {
            ClaimsPrincipal claims = _tokenManager.Decode(token, Encoding.ASCII.GetBytes(_configuration.GetSection("Jwt")["ResetPasswordSecretKey"]));
            var             claim  = claims.Claims.ToList();
            string          email  = claim[1].Value;

            var(user, _) = await _repository.AuthenticateUser(email);

            if (await _caching.GetCachedResponseAsync(token) != null)
            {
                await _caching.RemoveCacheByKeyAsync(token);

                return(await _repository.ResetPassword(user, BCrypt.Net.BCrypt.HashPassword(password)));
            }
            return(0);
        }