账号密码支持自定义更新周期
parent
e0523d1c2d
commit
471c8825ba
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.Cookie;
|
import javax.servlet.http.Cookie;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
@ -10,7 +11,9 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import com.ruoyi.common.config.Global;
|
import com.ruoyi.common.config.Global;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.text.Convert;
|
||||||
import com.ruoyi.common.utils.CookieUtils;
|
import com.ruoyi.common.utils.CookieUtils;
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.framework.util.ShiroUtils;
|
import com.ruoyi.framework.util.ShiroUtils;
|
||||||
|
@ -46,10 +49,10 @@ public class SysIndexController extends BaseController
|
||||||
mmap.put("sideTheme", configService.selectConfigByKey("sys.index.sideTheme"));
|
mmap.put("sideTheme", configService.selectConfigByKey("sys.index.sideTheme"));
|
||||||
mmap.put("skinName", configService.selectConfigByKey("sys.index.skinName"));
|
mmap.put("skinName", configService.selectConfigByKey("sys.index.skinName"));
|
||||||
mmap.put("ignoreFooter", configService.selectConfigByKey("sys.index.ignoreFooter"));
|
mmap.put("ignoreFooter", configService.selectConfigByKey("sys.index.ignoreFooter"));
|
||||||
mmap.put("initPasswordModify", configService.selectConfigByKey("sys.account.initPasswordModify"));
|
|
||||||
mmap.put("copyrightYear", Global.getCopyrightYear());
|
mmap.put("copyrightYear", Global.getCopyrightYear());
|
||||||
mmap.put("demoEnabled", Global.isDemoEnabled());
|
mmap.put("demoEnabled", Global.isDemoEnabled());
|
||||||
mmap.put("isDefaultPwd", user.getPwdUpdateDate() == null);
|
mmap.put("isDefaultModifyPwd", initPasswordIsModify(user.getPwdUpdateDate()));
|
||||||
|
mmap.put("isPasswordExpired", passwordIsExpiration(user.getPwdUpdateDate()));
|
||||||
|
|
||||||
// 菜单导航显示风格
|
// 菜单导航显示风格
|
||||||
String menuStyle = configService.selectConfigByKey("sys.index.menuStyle");
|
String menuStyle = configService.selectConfigByKey("sys.index.menuStyle");
|
||||||
|
@ -91,4 +94,28 @@ public class SysIndexController extends BaseController
|
||||||
mmap.put("version", Global.getVersion());
|
mmap.put("version", Global.getVersion());
|
||||||
return "main";
|
return "main";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查初始密码是否提醒修改
|
||||||
|
public boolean initPasswordIsModify(Date pwdUpdateDate)
|
||||||
|
{
|
||||||
|
int initPasswordModify = Convert.toInt(configService.selectConfigByKey("sys.account.initPasswordModify"));
|
||||||
|
return initPasswordModify == 1 && pwdUpdateDate == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查密码是否过期
|
||||||
|
public boolean passwordIsExpiration(Date pwdUpdateDate)
|
||||||
|
{
|
||||||
|
int passwordValidataDays = Convert.toInt(configService.selectConfigByKey("sys.account.passwordValidataDays"));
|
||||||
|
if (passwordValidataDays > 0)
|
||||||
|
{
|
||||||
|
if (StringUtils.isNull(pwdUpdateDate))
|
||||||
|
{
|
||||||
|
// 如果从未修改过初始密码,直接提醒过期
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Date nowDate = DateUtils.getNowDate();
|
||||||
|
return DateUtils.differentDaysByMillisecond(nowDate, pwdUpdateDate) > passwordValidataDays;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -393,7 +393,7 @@ $(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 初始密码提示 */
|
/* 初始密码提示 */
|
||||||
if([[${initPasswordModify}]] == 1 && [[${isDefaultPwd}]] == true) {
|
if([[${isDefaultModifyPwd}]]) {
|
||||||
layer.confirm("您的密码还是初始密码,请修改密码!", {
|
layer.confirm("您的密码还是初始密码,请修改密码!", {
|
||||||
icon: 0,
|
icon: 0,
|
||||||
title: "安全提示",
|
title: "安全提示",
|
||||||
|
@ -404,6 +404,19 @@ $(function() {
|
||||||
layer.close(index);
|
layer.close(index);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 过期密码提示 */
|
||||||
|
if([[${isPasswordExpired}]]) {
|
||||||
|
layer.confirm("您的密码已过期,请尽快修改密码!", {
|
||||||
|
icon: 0,
|
||||||
|
title: "安全提示",
|
||||||
|
btn: ['确认' , '取消'],
|
||||||
|
offset: ['30%']
|
||||||
|
}, function (index) {
|
||||||
|
resetPwd();
|
||||||
|
layer.close(index);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -333,7 +333,7 @@ $(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 初始密码提示 */
|
/* 初始密码提示 */
|
||||||
if([[${initPasswordModify}]] == 1 && [[${isDefaultPwd}]] == true) {
|
if([[${isDefaultModifyPwd}]]) {
|
||||||
layer.confirm("您的密码还是初始密码,请修改密码!", {
|
layer.confirm("您的密码还是初始密码,请修改密码!", {
|
||||||
icon: 0,
|
icon: 0,
|
||||||
title: "安全提示",
|
title: "安全提示",
|
||||||
|
@ -344,6 +344,19 @@ $(function() {
|
||||||
layer.close(index);
|
layer.close(index);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 过期密码提示 */
|
||||||
|
if([[${isPasswordExpired}]]) {
|
||||||
|
layer.confirm("您的密码已过期,请尽快修改密码!", {
|
||||||
|
icon: 0,
|
||||||
|
title: "安全提示",
|
||||||
|
btn: ['确认' , '取消'],
|
||||||
|
offset: ['30%']
|
||||||
|
}, function (index) {
|
||||||
|
resetPwd();
|
||||||
|
layer.close(index);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -74,7 +74,7 @@
|
||||||
removeUrl: prefix + "/remove",
|
removeUrl: prefix + "/remove",
|
||||||
exportUrl: prefix + "/export",
|
exportUrl: prefix + "/export",
|
||||||
sortName: "createTime",
|
sortName: "createTime",
|
||||||
sortOrder: "desc",
|
sortOrder: "asc",
|
||||||
modalName: "参数",
|
modalName: "参数",
|
||||||
columns: [{
|
columns: [{
|
||||||
checkbox: true
|
checkbox: true
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
removeUrl: prefix + "/remove",
|
removeUrl: prefix + "/remove",
|
||||||
exportUrl: prefix + "/export",
|
exportUrl: prefix + "/export",
|
||||||
sortName: "createTime",
|
sortName: "createTime",
|
||||||
sortOrder: "desc",
|
sortOrder: "asc",
|
||||||
modalName: "类型",
|
modalName: "类型",
|
||||||
columns: [{
|
columns: [{
|
||||||
checkbox: true
|
checkbox: true
|
||||||
|
|
|
@ -131,6 +131,14 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||||
return new Date(time);
|
return new Date(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算相差天数
|
||||||
|
*/
|
||||||
|
public static int differentDaysByMillisecond(Date date1, Date date2)
|
||||||
|
{
|
||||||
|
return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算两个时间差
|
* 计算两个时间差
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -532,14 +532,15 @@ create table sys_config (
|
||||||
primary key (config_id)
|
primary key (config_id)
|
||||||
) engine=innodb auto_increment=100 comment = '参数配置表';
|
) engine=innodb auto_increment=100 comment = '参数配置表';
|
||||||
|
|
||||||
insert into sys_config values(1, '主框架页-默认皮肤样式名称', 'sys.index.skinName', 'skin-blue', 'Y', 'admin', sysdate(), '', null, '蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow');
|
insert into sys_config values(1, '主框架页-默认皮肤样式名称', 'sys.index.skinName', 'skin-blue', 'Y', 'admin', sysdate(), '', null, '蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow');
|
||||||
insert into sys_config values(2, '用户管理-账号初始密码', 'sys.user.initPassword', '123456', 'Y', 'admin', sysdate(), '', null, '初始化密码 123456');
|
insert into sys_config values(2, '用户管理-账号初始密码', 'sys.user.initPassword', '123456', 'Y', 'admin', sysdate(), '', null, '初始化密码 123456');
|
||||||
insert into sys_config values(3, '主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 'admin', sysdate(), '', null, '深黑主题theme-dark,浅色主题theme-light,深蓝主题theme-blue');
|
insert into sys_config values(3, '主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 'admin', sysdate(), '', null, '深黑主题theme-dark,浅色主题theme-light,深蓝主题theme-blue');
|
||||||
insert into sys_config values(4, '账号自助-是否开启用户注册功能', 'sys.account.registerUser', 'false', 'Y', 'admin', sysdate(), '', null, '是否开启注册用户功能(true开启,false关闭)');
|
insert into sys_config values(4, '账号自助-是否开启用户注册功能', 'sys.account.registerUser', 'false', 'Y', 'admin', sysdate(), '', null, '是否开启注册用户功能(true开启,false关闭)');
|
||||||
insert into sys_config values(5, '用户管理-密码字符范围', 'sys.account.chrtype', '0', 'Y', 'admin', sysdate(), '', null, '默认任意字符范围,0任意(密码可以输入任意字符),1数字(密码只能为0-9数字),2英文字母(密码只能为a-z和A-Z字母),3字母和数字(密码必须包含字母,数字),4字母数组和特殊字符(密码必须包含字母,数字,特殊字符-_)');
|
insert into sys_config values(5, '用户管理-密码字符范围', 'sys.account.chrtype', '0', 'Y', 'admin', sysdate(), '', null, '默认任意字符范围,0任意(密码可以输入任意字符),1数字(密码只能为0-9数字),2英文字母(密码只能为a-z和A-Z字母),3字母和数字(密码必须包含字母,数字),4字母数组和特殊字符(密码必须包含字母,数字,特殊字符-_)');
|
||||||
insert into sys_config values(6, '用户管理-初始密码修改策略', 'sys.account.initPasswordModify', '0', 'Y', 'admin', sysdate(), '', null, '0:初始密码修改策略关闭,没有任何提示,1:提醒用户,如果未修改初始密码,则在登录时就会提醒修改密码对话框');
|
insert into sys_config values(6, '用户管理-初始密码修改策略', 'sys.account.initPasswordModify', '0', 'Y', 'admin', sysdate(), '', null, '0:初始密码修改策略关闭,没有任何提示,1:提醒用户,如果未修改初始密码,则在登录时就会提醒修改密码对话框');
|
||||||
insert into sys_config values(7, '主框架页-菜单导航显示风格', 'sys.index.menuStyle', 'default', 'Y', 'admin', sysdate(), '', null, '菜单导航显示风格(default为左侧导航菜单,topnav为顶部导航菜单)');
|
insert into sys_config values(7, '用户管理-账号密码更新周期', 'sys.account.passwordValidataDays', '0', 'Y', 'admin', sysdate(), '', null, '密码更新周期(填写数字,数据初始化值为0不限制,若修改必须为大于0小于365的正整数),如果超过这个周期登录系统时,则在登录时就会提醒修改密码对话框');
|
||||||
insert into sys_config values(8, '主框架页-是否开启页脚', 'sys.index.ignoreFooter', 'true', 'Y', 'admin', sysdate(), '', null, '是否开启底部页脚显示(true显示,false隐藏)');
|
insert into sys_config values(8, '主框架页-菜单导航显示风格', 'sys.index.menuStyle', 'default', 'Y', 'admin', sysdate(), '', null, '菜单导航显示风格(default为左侧导航菜单,topnav为顶部导航菜单)');
|
||||||
|
insert into sys_config values(9, '主框架页-是否开启页脚', 'sys.index.ignoreFooter', 'true', 'Y', 'admin', sysdate(), '', null, '是否开启底部页脚显示(true显示,false隐藏)');
|
||||||
|
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
|
Loading…
Reference in New Issue