예제 #1
0
        /// <summary>
        /// Used for local authentication
        /// </summary>
        /// <param name="email">Local user account email</param>
        /// <param name="password">Password</param>
        /// <returns></returns>
        public async Task <UserAccountVerificationResult> VerifyByEmailAndPasswordAsyc(string email, string password)
        {
            if (String.IsNullOrWhiteSpace(email))
            {
                throw new ArgumentNullException(nameof(email));
            }

            var result      = new UserAccountVerificationResult();
            var userAccount = await _userAccountStore.LoadByEmailAsync(email.ToLower());

            if (userAccount == null)
            {
                return(result);
            }

            result.IsPasswordValid = _crypto.VerifyPasswordHash(userAccount.PasswordHash, password,
                                                                _applicationOptions.PasswordHashingIterationCount);

            result.UserAccount        = userAccount;
            result.IsLoginAllowed     = userAccount.IsLoginAllowed;
            result.NeedChangePassword = false;
            result.IsLocalAccount     = userAccount.HasPassword();

            return(result);
        }
예제 #2
0
        VerifyByEmailAndPasswordAsync(
            string email,
            string password)
        {
            if (String.IsNullOrWhiteSpace(email))
            {
                throw new ArgumentNullException(nameof(email));
            }

            var result = new UserAccountVerificationResult();

            UserAccount userAccount = await userAccountStore
                                      .LoadByEmailAsync(email.ToLower());

            if (userAccount == null)
            {
                return(result);
            }

            if (userAccount.HasPassword())
            {
                result.IsLocalAccount = true;

                result.IsPasswordValid = crypto.VerifyPasswordHash(
                    userAccount.PasswordHash,
                    password,
                    applicationOptions.PasswordHashingIterationCount
                    );
            }

            result.UserAccount        = userAccount;
            result.IsLoginAllowed     = userAccount.IsLoginAllowed;
            result.NeedChangePassword = false;

            if (!result.IsPasswordValid && !result.IsLocalAccount)
            {
                string[] hints = userAccount.Accounts
                                 .Select(s => s.Provider).ToArray();
            }

            return(result);
        }