示例#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;

            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);
        }