Example #1
0
        public static string ChangePassword(Manager manager, string oldPassword, string newPassword,
                                            string confirmPassword, string ipstring)
        {
            if (string.IsNullOrEmpty(oldPassword))
            {
                return(ResponseCode.Managaer.OldPasswordNullOrEmpty);
            }
            if (string.IsNullOrEmpty(newPassword))
            {
                return(ResponseCode.Managaer.NewPasswordNullOrEmpty);
            }
            if (newPassword != confirmPassword)
            {
                return(ResponseCode.Managaer.ConfirmPasswordError);
            }
            Manager manage = managerRepository.GetById(manager.Id);

            if (manage != null)
            {
                if (!manage.MatchPassword(oldPassword))
                {
                    return(ResponseCode.Managaer.OldPasswordError);
                }
                PwdChangeRecord pwdChangeRecord = PwdChangeRecordFactory.Create(manager.Id, manager.RealName,
                                                                                oldPassword,
                                                                                newPassword, ipstring, manage.RealName);
                manage.Password = newPassword;
                manage.EncryptPassword();
                managerRepository.Save(manage);
                pwdChangeRecordRepository.Save(pwdChangeRecord);
                manager = manage;
                return(ResponseCode.Ok);
            }
            return(ResponseCode.NotFoundData);
        }
Example #2
0
        public static void ResetPassword(long id, Manager currentManager, string ipString)
        {
            Manager manager = managerRepository.GetById(id);

            if (manager != null)
            {
                PwdChangeRecord pwdChangeRecord = PwdChangeRecordFactory.Create(id, manager.RealName, "重置密码",
                                                                                "123456", ipString, currentManager.RealName);
                manager.Password = "******";
                manager.EncryptPassword();
                managerRepository.Save(manager);
                pwdChangeRecordRepository.Save(pwdChangeRecord);
            }
        }