Пример #1
0
        public Task <string> LoginAsync(AuthRequest request)
        {
            var user = userSecurityRepository.GetByEmail(request.Email);

            user.CreateToken(abiokaToken, Guid.NewGuid().ToString());
            userSecurityRepository.Update(user);
            return(Task.FromResult(user.Token));
        }
Пример #2
0
        protected override void DataValidate(AddUserRequest instance, ActionType actionType)
        {
            var tmpUser = userSecurityRepository.GetByEmail(instance.Email);

            if (tmpUser != null)
            {
                throw new DenialException("UserIsAlreadyRegistered", instance.Email);
            }
        }
Пример #3
0
        public void ResetPassword(string email)
        {
            var user = userSecurityRepository.GetByEmail(email);

            if (user == null)
            {
                return;
            }

            user.ResetPassword();
            userSecurityRepository.Update(user);
        }
Пример #4
0
        protected override void DataValidate(SendVerificationEmailRequest instance, ActionType actionType)
        {
            var user = userSecurityRepository.GetByEmail(instance.Email);

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

            if (user.IsEmailVerified)
            {
                throw new DenialException("AccountIsAlreadyVerified");
            }
        }
Пример #5
0
        protected override void DataValidate(AuthRequest instance, ActionType actionType)
        {
            if (instance.provider != AuthProvider.Local)
            {
                return;
            }

            var user = userSecurityRepository.GetByEmail(instance.Email);

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

            var loginAttempt = new LoginAttempt {
                Date  = DateTime.UtcNow,
                Token = user.Token,
                User  = user,
                IP    = currentContext.Current.IP
            };

            if (!user.ArePasswordEqual(instance.Email, instance.Password))
            {
                loginAttempt.LoginResult = LoginResult.WrongPassword;
                loginAttemptRepository.Add(loginAttempt);

                throw new DenialException("WrongPassword");
            }

            if (!user.IsEmailVerified)
            {
                loginAttempt.LoginResult = LoginResult.UnverifiedEmail;
                loginAttemptRepository.Add(loginAttempt);

                throw new DenialException("EmailIsNotVerifiedCheckYourEmails");
            }

            if (user.IsDeleted)
            {
                loginAttempt.LoginResult = LoginResult.UserIsNotActive;
                loginAttemptRepository.Add(loginAttempt);

                throw new DenialException("UserIsNotActive");
            }

            loginAttempt.LoginResult = LoginResult.Successful;
            loginAttemptRepository.Add(loginAttempt);
        }
Пример #6
0
        public void SendVerificationEmail(SendVerificationEmailRequest request)
        {
            var user = userSecurityRepository.GetByEmail(request.Email);

            SendVerificationEmail(user);
        }