Ejemplo n.º 1
0
 public async Task <EmailVerification> GetEmailVerificationObjAsync(string code)
 {
     return(await Task.Factory.StartNew(() =>
     {
         var encryptedText = CryptoGraphy.ConvertBase64UrlToObject <string>(code);
         return JsonConvert.DeserializeObject <EmailVerification>(encryptedText);
     }));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Hashes the password.
        /// </summary>
        /// <param name="password">The password.</param>
        /// <returns>
        /// String Value
        /// </returns>
        public async Task <string> GetHashPassword(string password)
        {
            return(await Task.Factory.StartNew(() =>
            {
                if (password == null)
                {
                    throw new ArgumentNullException(nameof(password));
                }

                return CryptoGraphy.HashPasswordInternal(password);
            }));
        }
Ejemplo n.º 3
0
 public async Task <string> GetEmailVerificationCodeAsync(IApplicationUser applicationUser)
 {
     return(await Task.Factory.StartNew(() =>
     {
         return CryptoGraphy.EncryptObject(
             new EmailVerification
         {
             UserId = applicationUser.UserId.ToString(),
             Email = applicationUser.Email,
             SecurityStamp = applicationUser.SecurityStamp,
             ExpiryHour = DateTime.UtcNow
         });
     }));
 }
Ejemplo n.º 4
0
        public async Task <string> GetEmailVerificationCodeAsync(IApplicationUser applicationUser)
        {
            return(await Task.Factory.StartNew(() =>
            {
                var jsonObj = JsonConvert.SerializeObject(new EmailVerification
                {
                    UserId = applicationUser.UserId.ToString(),
                    Email = applicationUser.Email,
                    ExpiryHour = DateTime.UtcNow.AddHours(24)
                });

                return CryptoGraphy.ConvertToBase64Url(jsonObj);
            }));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Verifies the hashed password.
        /// </summary>
        /// <param name="hashedPassword">The hashed password.</param>
        /// <param name="password">The password.</param>
        /// <returns>
        /// String Value
        /// </returns>
        public async Task <bool> VerifyHashedPassword(string hashedPassword, string password)
        {
            return(await Task.Factory.StartNew(() =>
            {
                if (hashedPassword == null)
                {
                    throw new ArgumentNullException(nameof(hashedPassword));
                }
                if (password == null)
                {
                    throw new ArgumentNullException(nameof(password));
                }

                return CryptoGraphy.VerifyHashedPasswordInternal(hashedPassword, password);
            }));
        }