コード例 #1
0
        public static Boolean DataValidationController(string oldPass, string newPass, string confirmPass, User data, out string errorMessage)
        {
            errorMessage = "";
            if (oldPass == null || newPass == null || confirmPass == null)
            {
                errorMessage = "All fields must be filled in";
                return(false);
            }
            else if (ChangePasswordHandler.GetUserHandler(data.Email.ToString(), oldPass) == null)
            {
                errorMessage = "Old password not found";
                return(false);
            }
            else if (newPass.Length < 5)
            {
                errorMessage = "New password must be more than 5 character";
                return(false);
            }
            else if (newPass != confirmPass)
            {
                errorMessage = "Failed to confirm new password";
                return(false);
            }

            return(true);
        }
コード例 #2
0
 private static void ChangePassword()
 {
     var changePasswordHandler =
         new ChangePasswordHandler()
         .SetData("09013120129", "78220", "a123321");
     var response = changePasswordHandler.Process();
 }
        protected static void Initialize()
        {
            InitializeBus();
            ExceptionHandlerMock = new Mock <IExceptionHandler>();
            Handler               = new Handler(ExceptionHandlerMock.Object);
            PasswordServiceMock   = new Mock <IPasswordService>();
            ChangePasswordHandler = new ChangePasswordHandler(Handler,
                                                              BusClientMock.Object, PasswordServiceMock.Object);

            Command = new ChangePassword
            {
                CurrentPassword = "******",
                NewPassword     = "******",
                UserId          = "userId",
                Request         = new Request
                {
                    Id        = Guid.NewGuid(),
                    CreatedAt = DateTime.Now,
                    Culture   = "en-US",
                    Name      = "name",
                    Origin    = "collectively",
                    Resource  = "resource"
                }
            };
        }
コード例 #4
0
 public UserController()
 {
     _loginHandler    = new LoginHandler();
     _registerHandler = new RegisterHandler();
     _sendRegistrationVerificationCodeHandler = new SendRegistrationVerificationCodeHandler();
     _changePasswordHandler = new ChangePasswordHandler();
     _sendPasswordRecoveryVerificationCodeHandler = new SendPasswordRecoveryVerificationCodeHandler();
 }
コード例 #5
0
 public UsersController(GetUserHandler getUserHandler, CreateUserHandler createUserHandler, ChangePasswordHandler changePasswordHandler, ResetPasswordStepOneHandler resetPasswordStepOneHandler, ValidateResetPasswordTokenHandler validateResetPasswordTokenHandler, ResetPasswordStepTwoHandler resetPasswordStepTwoHandler,
                        ChangeProfileSettingsHandler changeProfileSettingsHandler)
 {
     _getUserHandler                    = getUserHandler;
     _createUserHandler                 = createUserHandler;
     _changePasswordHandler             = changePasswordHandler;
     _resetPasswordStepOneHandler       = resetPasswordStepOneHandler;
     _validateResetPasswordTokenHandler = validateResetPasswordTokenHandler;
     _resetPasswordStepTwoHandler       = resetPasswordStepTwoHandler;
     _changeProfileSettingsHandler      = changeProfileSettingsHandler;
 }
コード例 #6
0
        private static (User fakeUser, ChangePasswordHandler sut, IUserRepository userRepository) Arrange()
        {
            var userRepository = Substitute.For <IUserRepository>();
            var passwordHasher = new PasswordHasher <User>();
            var fakeUser       = FakeCredentialsProvider.GetUser(passwordHasher);

            var sut = new ChangePasswordHandler(
                userRepository,
                passwordHasher
                );

            return(fakeUser, sut, userRepository);
        }
コード例 #7
0
        public void SetUp()
        {
            BodyFitTrackerContext bodyFitTrackerContext = DatabaseConnectionFactory.GetInMemoryDatabase(true);
            AppUser appUser = new AppUser("*****@*****.**", _userPassword, "", 60, GenderType.Male, MeasurementSystem.Imperial);

            bodyFitTrackerContext.Add(appUser);
            bodyFitTrackerContext.SaveChanges();

            var passwordHasherMock = new Mock <IPasswordHasher>();
            var userAccessorMock   = new Mock <IUserAccessor>();

            userAccessorMock.Setup(x => x.GetCurrentUserId()).Returns(appUser.AppUserId);
            passwordHasherMock.Setup(x => x.ValidatePlainTextPassword(_userPassword, It.IsAny <string>(), It.IsAny <string>())).Returns(true);
            passwordHasherMock.Setup(x => x.GeneratePassword(It.IsAny <string>())).Returns((string password) => (password, ""));

            _changePasswordHandler = new ChangePasswordHandler(bodyFitTrackerContext, passwordHasherMock.Object, userAccessorMock.Object);
        }
コード例 #8
0
        public static bool validatePassword(int userID, string oldpass, string newpass, string confpass, out string errorMsg)
        {
            bool pass = ChangePasswordHandler.checkOldPassword(userID, oldpass);

            errorMsg = "";
            if (!pass)
            {
                errorMsg = "Old Password not match";
                return(false);
            }
            else if (newpass == "" || oldpass == "" || confpass == "")
            {
                errorMsg = "Data must be filled!";
                return(false);
            }
            else if (oldpass == newpass)
            {
                errorMsg = "New password must be different from old password";
                return(false);
            }
            else if (newpass != confpass)
            {
                errorMsg = "Confirmation password must be same with New Password!";
                return(false);
            }
            else if (newpass.Length <= 5)
            {
                errorMsg = "Must be longer than 5 characters";
                return(false);
            }
            else
            {
                changePassword(userID, oldpass, newpass);
                return(true);
            }
        }
コード例 #9
0
 public static void UpdateUserPasswordController(int id, string newPassword)
 {
     ChangePasswordHandler.UpdateUserPasswordHandler(id, newPassword);
 }
コード例 #10
0
 public static void changePassword(int id, string oldpass, string newpass)
 {
     ChangePasswordHandler.ChangePassword(id, oldpass, newpass);
 }