Example #1
0
        public async Task <bool> UpdatePassword(JwtTokenContent token, string password)
        {
            string passwordHash = BCrypt.Net.BCrypt.HashPassword(password);

            try
            {
                await _userStore.UpdatePassword(token.UserId, passwordHash);

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Example #2
0
        internal static string InternalGenerateUserToken(string email, DateTime validityDate, string userId, string signatureKey, bool isValidationEmail)
        {
            var payload = new JwtTokenContent()
            {
                Email     = email,
                ExpiresAt = validityDate,
                UserId    = userId,
            };

            if (isValidationEmail)
            {
                payload.SpecialRights = "validate-email";
            }

            var    privateKey = Encoding.UTF8.GetBytes(signatureKey);
            string token      = Jose.JWT.Encode(payload, privateKey, JwsAlgorithm.HS512);

            return(token);
        }
Example #3
0
        public async Task <string> RefreshToken(JwtTokenContent token)
        {
            var newToken = GenerateUserToken(token.Email, DateTime.UtcNow.AddMinutes(_defaultTokenValidityPeriod), token.UserId);

            return(newToken);
        }