提交 2db59b9e 编写于 作者: hlwwx's avatar hlwwx

'个人信息增加密码过期时间'

上级 240ab4a9
......@@ -3,6 +3,7 @@ package com.x.organization.assemble.control.factory;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
......@@ -187,7 +188,7 @@ public class PersonFactory extends AbstractFactory {
throw new Exception("find duplicate value{" + StringUtils.join(list, ",") + "}");
}
public void setPassword(Person person, String password) throws Exception {
public void setPassword(Person person, String password, boolean isInitialization ) throws Exception {
Calendar cal = Calendar.getInstance();
person.setChangePasswordTime(cal.getTime());
person.setPassword(Crypto.encrypt(password, Config.token().getKey()));
......@@ -195,8 +196,12 @@ public class PersonFactory extends AbstractFactory {
if (passwordPeriod == null || passwordPeriod <= 0) {
person.setPasswordExpiredTime(null);
} else {
cal.add(Calendar.DATE, passwordPeriod);
person.setPasswordExpiredTime(cal.getTime());
if(isInitialization) {
person.setPasswordExpiredTime(new Date());
}else {
cal.add(Calendar.DATE, passwordPeriod);
person.setPasswordExpiredTime(cal.getTime());
}
}
}
......
......@@ -27,7 +27,7 @@ public class ActionSetPassword {
}
Person person = emc.find(personId, Person.class, ExceptionWhen.not_found);
emc.beginTransaction(Person.class);
business.person().setPassword(person, wrapIn.getValue());
business.person().setPassword(person, wrapIn.getValue(),false);
emc.check(person, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Person.class);
......
......@@ -78,9 +78,9 @@ class ActionCreate extends BaseAction {
/** 不设置默认头像,可以通过为空直接显示默认头像 */
if (StringUtils.isNotEmpty(wi.getPassword())) {
business.person().setPassword(person, wi.getPassword());
business.person().setPassword(person, wi.getPassword(),true);
} else {
business.person().setPassword(person, this.initPassword(business, person));
business.person().setPassword(person, this.initPassword(business, person),true);
}
/** 设置默认管理员 */
this.convertControllerList(effectivePerson, business, person);
......
......@@ -29,7 +29,7 @@ class ActionResetPassword extends BaseAction {
if (!business.editable(effectivePerson, o)) {
throw new ExceptionDenyEditPerson(effectivePerson, flag);
}
business.person().setPassword(o, this.initPassword(business, o));
business.person().setPassword(o, this.initPassword(business, o),true);
emc.beginTransaction(Person.class);
emc.check(o, CheckPersistType.all);
emc.commit();
......
......@@ -38,7 +38,7 @@ class ActionSetPassword extends BaseAction {
throw new ExceptionPasswordEmpty();
}
emc.beginTransaction(Person.class);
business.person().setPassword(o, wi.getValue());
business.person().setPassword(o, wi.getValue(),false);
emc.check(o, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Person.class);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册