Пример #1
0
        public void VerifyEmail(string encodedToken)
        {
            var providerToken = encodedToken.DecodeBase64();
            var user          = userSecurityRepository.Query().Where(u => u.ProviderToken == providerToken && !u.IsEmailVerified).FirstOrDefault();

            if (user == null)
            {
                return;
            }

            user.VerifyEmail();
            userSecurityRepository.Update(user);
        }
Пример #2
0
        protected override void DataValidate(NewPasswordRequest instance, ActionType actionType)
        {
            var providerToken = instance.Token.DecodeBase64();
            var user          = userSecurityRepository.Query().Where(u => u.ProviderToken == providerToken).FirstOrDefault();

            if (user == null)
            {
                throw new DenialException(HttpStatusCode.NotFound, "UserNotFound");
            }

            if (user.AuthProvider != AuthProvider.Local)
            {
                throw new DenialException("PasswordCannotBeChanged");
            }

            if (!user.IsEmailVerified)
            {
                throw new DenialException(HttpStatusCode.NotFound, "PleaseVerifyYourAccount");
            }
        }