Compare commits
10 Commits
0728a04b1b
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41720e624c | ||
|
|
09f1b3495f | ||
|
|
1a8d111459 | ||
|
|
87d02b0e41 | ||
|
|
7da12b0c07 | ||
|
|
dbe9834e4c | ||
|
|
69aaabd09d | ||
|
|
557efc4d44 | ||
|
|
58f3c43c50 | ||
|
|
d454d9729e |
14
pom.xml
14
pom.xml
@@ -17,20 +17,20 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>17</java.version>
|
||||
<spring-boot.version>4.0.3</spring-boot.version>
|
||||
<spring-boot.version>4.0.6</spring-boot.version>
|
||||
<mybatis-spring-boot.version>4.0.1</mybatis-spring-boot.version>
|
||||
<druid.version>1.2.28</druid.version>
|
||||
<yauaa.version>8.1.0</yauaa.version>
|
||||
<yauaa.version>8.1.1</yauaa.version>
|
||||
<kaptcha.version>2.3.3</kaptcha.version>
|
||||
<pagehelper.boot.version>2.1.1</pagehelper.boot.version>
|
||||
<fastjson.version>2.0.61</fastjson.version>
|
||||
<oshi.version>6.10.0</oshi.version>
|
||||
<commons.io.version>2.21.0</commons.io.version>
|
||||
<pagehelper.boot.version>4.1.0</pagehelper.boot.version>
|
||||
<fastjson.version>2.0.62</fastjson.version>
|
||||
<oshi.version>7.3.0</oshi.version>
|
||||
<commons.io.version>2.22.0</commons.io.version>
|
||||
<poi.version>4.1.2</poi.version>
|
||||
<velocity.version>2.3</velocity.version>
|
||||
<jwt.version>0.9.1</jwt.version>
|
||||
<jaxb-api.version>2.3.1</jaxb-api.version>
|
||||
<springdoc.version>3.0.2</springdoc.version>
|
||||
<springdoc.version>3.0.3</springdoc.version>
|
||||
</properties>
|
||||
|
||||
<!-- 依赖声明 -->
|
||||
|
||||
@@ -87,6 +87,7 @@ public class SysLoginController
|
||||
ajax.put("user", user);
|
||||
ajax.put("roles", roles);
|
||||
ajax.put("permissions", permissions);
|
||||
ajax.put("pwdChrtype", getSysAccountChrtype());
|
||||
ajax.put("isDefaultModifyPwd", initPasswordIsModify(user.getPwdUpdateDate()));
|
||||
ajax.put("isPasswordExpired", passwordIsExpiration(user.getPwdUpdateDate()));
|
||||
return ajax;
|
||||
@@ -105,6 +106,12 @@ public class SysLoginController
|
||||
return AjaxResult.success(menuService.buildMenus(menus));
|
||||
}
|
||||
|
||||
// 获取用户密码自定义配置规则
|
||||
public String getSysAccountChrtype()
|
||||
{
|
||||
return Convert.toStr(configService.selectConfigByKey("sys.account.chrtype"), "0");
|
||||
}
|
||||
|
||||
// 检查初始密码是否提醒修改
|
||||
public boolean initPasswordIsModify(Date pwdUpdateDate)
|
||||
{
|
||||
|
||||
@@ -127,7 +127,7 @@ public class SysNoticeController extends BaseController
|
||||
* 已读用户列表数据
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:list')")
|
||||
@PostMapping("/readUsers/list")
|
||||
@GetMapping("/readUsers/list")
|
||||
@ResponseBody
|
||||
public TableDataInfo readUsersList(Long noticeId, String searchValue)
|
||||
{
|
||||
|
||||
@@ -19,10 +19,8 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
@@ -128,14 +126,8 @@ public class SysRoleController extends BaseController
|
||||
|
||||
if (roleService.updateRole(role) > 0)
|
||||
{
|
||||
// 更新缓存用户权限
|
||||
LoginUser loginUser = getLoginUser();
|
||||
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin())
|
||||
{
|
||||
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
|
||||
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
|
||||
tokenService.setLoginUser(loginUser);
|
||||
}
|
||||
// 刷新所有持有该角色的在线用户权限
|
||||
tokenService.refreshPermissionByRoleId(role.getRoleId(), permissionService);
|
||||
return success();
|
||||
}
|
||||
return error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
<!-- JSON工具类 -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<groupId>tools.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import tools.jackson.databind.annotation.JsonSerialize;
|
||||
import com.ruoyi.common.config.serializer.SensitiveJsonSerializer;
|
||||
import com.ruoyi.common.enums.DesensitizedType;
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.ruoyi.common.enums.DesensitizedType;
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@Target({ ElementType.FIELD, ElementType.METHOD })
|
||||
@JacksonAnnotationsInside
|
||||
@JsonSerialize(using = SensitiveJsonSerializer.class)
|
||||
public @interface Sensitive
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.ruoyi.common.config.serializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.BeanProperty;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.ser.ContextualSerializer;
|
||||
import tools.jackson.core.JacksonException;
|
||||
import tools.jackson.core.JsonGenerator;
|
||||
import tools.jackson.databind.BeanProperty;
|
||||
import tools.jackson.databind.DatabindException;
|
||||
import tools.jackson.databind.SerializationContext;
|
||||
import tools.jackson.databind.ValueSerializer;
|
||||
import tools.jackson.databind.ser.std.StdSerializer;
|
||||
import com.ruoyi.common.annotation.Sensitive;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.enums.DesensitizedType;
|
||||
@@ -18,14 +18,26 @@ import com.ruoyi.common.utils.SecurityUtils;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class SensitiveJsonSerializer extends JsonSerializer<String> implements ContextualSerializer
|
||||
public class SensitiveJsonSerializer extends StdSerializer<String>
|
||||
{
|
||||
private DesensitizedType desensitizedType;
|
||||
private final DesensitizedType desensitizedType;
|
||||
|
||||
public SensitiveJsonSerializer()
|
||||
{
|
||||
super(String.class);
|
||||
this.desensitizedType = null;
|
||||
}
|
||||
|
||||
public SensitiveJsonSerializer(DesensitizedType desensitizedType)
|
||||
{
|
||||
super(String.class);
|
||||
this.desensitizedType = desensitizedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException
|
||||
public void serialize(String value, JsonGenerator gen, SerializationContext ctxt) throws JacksonException
|
||||
{
|
||||
if (desensitization())
|
||||
if (desensitizedType != null && desensitization())
|
||||
{
|
||||
gen.writeString(desensitizedType.desensitizer().apply(value));
|
||||
}
|
||||
@@ -36,16 +48,14 @@ public class SensitiveJsonSerializer extends JsonSerializer<String> implements C
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property)
|
||||
throws JsonMappingException
|
||||
public ValueSerializer<?> createContextual(SerializationContext ctxt, BeanProperty property) throws DatabindException
|
||||
{
|
||||
Sensitive annotation = property.getAnnotation(Sensitive.class);
|
||||
if (Objects.nonNull(annotation) && Objects.equals(String.class, property.getType().getRawClass()))
|
||||
{
|
||||
this.desensitizedType = annotation.desensitizedType();
|
||||
return this;
|
||||
return new SensitiveJsonSerializer(annotation.desensitizedType());
|
||||
}
|
||||
return prov.findValueSerializer(property.getType(), property);
|
||||
return ctxt.findValueSerializer(property.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,7 @@ public class MimeTypeUtils
|
||||
// 图片
|
||||
"bmp", "gif", "jpg", "jpeg", "png",
|
||||
// word excel powerpoint
|
||||
"doc", "docx", "xls", "xlsx", "ppt", "pptx", "html", "htm", "txt",
|
||||
"doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt",
|
||||
// 压缩文件
|
||||
"rar", "zip", "gz", "bz2",
|
||||
// 视频格式
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.ruoyi.framework.web.service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -22,6 +22,7 @@ import com.ruoyi.common.utils.uuid.IdUtils;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* token验证处理
|
||||
@@ -229,4 +230,41 @@ public class TokenService
|
||||
{
|
||||
return CacheConstants.LOGIN_TOKEN_KEY + uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色权限变更后,刷新所有持有该角色的在线用户权限
|
||||
*
|
||||
* @param roleId 变更的角色ID
|
||||
* @param permissionService 权限服务
|
||||
*/
|
||||
public void refreshPermissionByRoleId(Long roleId, SysPermissionService permissionService)
|
||||
{
|
||||
// 扫描所有在线 token
|
||||
String pattern = CacheConstants.LOGIN_TOKEN_KEY + "*";
|
||||
Collection<String> keys = redisCache.keys(pattern);
|
||||
if (keys == null || keys.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (String key : keys)
|
||||
{
|
||||
LoginUser loginUser = redisCache.getCacheObject(key);
|
||||
if (loginUser == null || loginUser.getUser() == null || loginUser.getUser().isAdmin())
|
||||
{
|
||||
// 管理员拥有所有权限,跳过
|
||||
continue;
|
||||
}
|
||||
// 判断该用户是否拥有此角色
|
||||
boolean hasRole = loginUser.getUser().getRoles() != null
|
||||
&& loginUser.getUser().getRoles().stream().anyMatch(r -> roleId.equals(r.getRoleId()));
|
||||
if (!hasRole)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// 刷新权限缓存
|
||||
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
|
||||
refreshToken(loginUser);
|
||||
log.info("角色[{}]权限变更,已刷新在线用户[{}]的权限缓存", roleId, loginUser.getUsername());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<set>
|
||||
<if test="columnComment != null">column_comment = #{columnComment},</if>
|
||||
<if test="javaType != null">java_type = #{javaType},</if>
|
||||
<if test="columnType != null">column_type = #{columnType},</if>
|
||||
<if test="javaField != null">java_field = #{javaField},</if>
|
||||
<if test="isInsert != null">is_insert = #{isInsert},</if>
|
||||
<if test="isEdit != null">is_edit = #{isEdit},</if>
|
||||
|
||||
@@ -315,7 +315,7 @@
|
||||
<script setup lang="ts" name="${BusinessName}">
|
||||
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"
|
||||
#if($genView)
|
||||
import ${BusinessName}ViewDrawer from "./view"
|
||||
import ${BusinessName}ViewDrawer from "./view.vue"
|
||||
#end
|
||||
import type { ${ClassName}, ${BusinessName}QueryParams } from "@/types/api/${moduleName}/${businessName}"
|
||||
import type { TreeSelect } from '@/types/api/common'
|
||||
|
||||
@@ -394,7 +394,7 @@ import type { ${ClassName}, ${BusinessName}QueryParams } from "@/types/api/${mod
|
||||
#end
|
||||
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"
|
||||
#if($genView)
|
||||
import ${BusinessName}ViewDrawer from "./view"
|
||||
import ${BusinessName}ViewDrawer from "./view.vue"
|
||||
#end
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
@@ -73,7 +73,7 @@ export function markNoticeReadAll(ids) {
|
||||
export function listNoticeReadUsers(query) {
|
||||
return request({
|
||||
url: '/system/notice/readUsers/list',
|
||||
method: 'post',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ export default {
|
||||
return {
|
||||
'--chrome-tab-active-bg': this.mixHexWithWhite(primary, 0.15),
|
||||
'--chrome-tab-text-active': primary,
|
||||
'--chrome-wing-r': '14px'
|
||||
'--chrome-wing-r': '10px'
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -610,16 +610,19 @@ $tags-bar-height: 34px;
|
||||
background: #f5f7fa !important;
|
||||
border-radius: 6px 6px 0 0;
|
||||
color: #303133 !important;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
&.active {
|
||||
height: 31px;
|
||||
min-height: 31px;
|
||||
height: 33px;
|
||||
min-height: 33px;
|
||||
padding: 0 14px;
|
||||
z-index: 3;
|
||||
color: var(--chrome-tab-text-active) !important;
|
||||
font-weight: 500;
|
||||
background: var(--chrome-tab-active-bg) !important;
|
||||
border: none !important;
|
||||
border-bottom: 2px solid var(--chrome-tab-active-bg) !important;
|
||||
border-radius: var(--chrome-wing-r) var(--chrome-wing-r) 0 0;
|
||||
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
|
||||
|
||||
@@ -690,12 +693,33 @@ $tags-bar-height: 34px;
|
||||
.el-scrollbar__bar {
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s;
|
||||
z-index: 10;
|
||||
|
||||
.tags-view-container:hover & {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.tags-view-container--chrome & {
|
||||
.el-scrollbar {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.el-scrollbar__wrap {
|
||||
&::-webkit-scrollbar {
|
||||
width: 0 !important;
|
||||
height: 0 !important;
|
||||
}
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
}
|
||||
|
||||
.el-scrollbar__bar.is-horizontal {
|
||||
z-index: 20;
|
||||
height: 6px !important;
|
||||
}
|
||||
}
|
||||
|
||||
.tags-view-item {
|
||||
.el-icon-close {
|
||||
width: 16px;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import store from '@/store'
|
||||
import router from '@/router'
|
||||
import { MessageBox, } from 'element-ui'
|
||||
import cache from '@/plugins/cache'
|
||||
import { MessageBox } from 'element-ui'
|
||||
import { login, logout, getInfo } from '@/api/login'
|
||||
import { getToken, setToken, removeToken } from '@/utils/auth'
|
||||
import { isHttp, isEmpty } from "@/utils/validate"
|
||||
@@ -79,6 +80,7 @@ const user = {
|
||||
commit('SET_NAME', user.userName)
|
||||
commit('SET_NICK_NAME', user.nickName)
|
||||
commit('SET_AVATAR', avatar)
|
||||
cache.session.set('pwrChrtype', res.pwdChrtype)
|
||||
/* 初始密码提示 */
|
||||
if(res.isDefaultModifyPwd) {
|
||||
MessageBox.confirm('您的密码还是初始密码,请修改密码!', '安全提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => {
|
||||
|
||||
71
ruoyi-ui/src/utils/passwordRule.js
Normal file
71
ruoyi-ui/src/utils/passwordRule.js
Normal file
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* 密码强度规则
|
||||
* 根据参数 chrtype 动态生成校验规则
|
||||
*
|
||||
* chrtype 说明:
|
||||
* 0 - 任意字符(默认)
|
||||
* 1 - 纯数字(0-9)
|
||||
* 2 - 纯字母(a-z / A-Z)
|
||||
* 3 - 字母 + 数字(必须同时包含)
|
||||
* 4 - 字母 + 数字 + 特殊字符(必须同时包含,特殊字符:~!@#$%^&*()-=_+)
|
||||
*/
|
||||
import cache from '@/plugins/cache'
|
||||
|
||||
// 各类型对应的正则、错误提示
|
||||
const PWD_RULES = {
|
||||
'0': { pattern: /^[^<>"'|\\]+$/, message: '密码不能包含非法字符:< > " \' \\ |' },
|
||||
'1': { pattern: /^[0-9]+$/, message: '密码只能为数字(0-9)' },
|
||||
'2': { pattern: /^[a-zA-Z]+$/, message: '密码只能为英文字母(a-z、A-Z)' },
|
||||
'3': { pattern: /^(?=.*[a-zA-Z])(?=.*[0-9])[a-zA-Z0-9]+$/, message: '密码必须同时包含字母和数字' },
|
||||
'4': { pattern: /^(?=.*[A-Za-z])(?=.*\d)(?=.*[~!@#$%^&*()\-=_+])[A-Za-z\d~!@#$%^&*()\-=_+]+$/, message: '密码必须同时包含字母、数字和特殊字符(~!@#$%^&*()-=_+)' }
|
||||
}
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
// 密码限制类型
|
||||
pwdChrType: cache.session.get('pwrChrtype') || '0'
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 默认密码校验
|
||||
pwdValidator() {
|
||||
const rule = PWD_RULES[this.pwdChrType] || PWD_RULES['0']
|
||||
return [
|
||||
{ required: true, message: '密码不能为空', trigger: 'blur' },
|
||||
{ min: 6, max: 20, message: '密码长度必须介于 6 和 20 之间', trigger: 'blur' },
|
||||
{ pattern: rule.pattern, message: rule.message, trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
// 校验prompt的inputValidator函数
|
||||
pwdPromptValidator() {
|
||||
const rule = PWD_RULES['0']
|
||||
return (value) => {
|
||||
if (!value || value.length < 6 || value.length > 20) {
|
||||
return '密码长度必须介于 6 和 20 之间'
|
||||
}
|
||||
if (!rule.pattern.test(value)) {
|
||||
return rule.message
|
||||
}
|
||||
}
|
||||
},
|
||||
// 个人中心密码校验
|
||||
infoPwdValidator() {
|
||||
const rule = PWD_RULES[this.pwdChrType] || PWD_RULES['0']
|
||||
return [
|
||||
{ required: true, message: '新密码不能为空', trigger: 'blur' },
|
||||
{ min: 6, max: 20, message: '新密码长度必须介于 6 和 20 之间', trigger: 'blur' },
|
||||
{ pattern: rule.pattern, message: rule.message, trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
// 注册页面密码校验
|
||||
registerPwdValidator() {
|
||||
const rule = PWD_RULES['0']
|
||||
return [
|
||||
{ required: true, message: '请输入您的密码', trigger: 'blur' },
|
||||
{ min: 6, max: 20, message: '用户密码长度必须介于 6 和 20 之间', trigger: 'blur' },
|
||||
{ pattern: rule.pattern, message: rule.message, trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,12 @@
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
export function isPathMatch(pattern, path) {
|
||||
const regexPattern = pattern.replace(/\//g, '\\/').replace(/\*\*/g, '.*').replace(/\*/g, '[^\\/]*')
|
||||
const regexPattern = pattern
|
||||
.replace(/([.+^${}()|\[\]\\])/g, '\\$1')
|
||||
.replace(/\*\*/g, '__DOUBLE_STAR__')
|
||||
.replace(/\*/g, '[^/]*')
|
||||
.replace(/__DOUBLE_STAR__/g, '.*')
|
||||
.replace(/\?/g, '[^/]')
|
||||
const regex = new RegExp(`^${regexPattern}$`)
|
||||
return regex.test(path)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="password">
|
||||
<el-form-item prop="password" :rules="registerPwdValidator">
|
||||
<el-input
|
||||
v-model="registerForm.password"
|
||||
type="password"
|
||||
@@ -68,18 +68,12 @@
|
||||
|
||||
<script>
|
||||
import { getCodeImg, register } from "@/api/login"
|
||||
import passwordRule from "@/utils/passwordRule"
|
||||
import defaultSettings from '@/settings'
|
||||
|
||||
export default {
|
||||
name: "Register",
|
||||
mixins: [passwordRule],
|
||||
data() {
|
||||
const equalToPassword = (rule, value, callback) => {
|
||||
if (this.registerForm.password !== value) {
|
||||
callback(new Error("两次输入的密码不一致"))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
return {
|
||||
title: process.env.VUE_APP_TITLE,
|
||||
footerContent: defaultSettings.footerContent,
|
||||
@@ -91,24 +85,31 @@ export default {
|
||||
code: "",
|
||||
uuid: ""
|
||||
},
|
||||
registerRules: {
|
||||
loading: false,
|
||||
captchaEnabled: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
registerRules() {
|
||||
return {
|
||||
username: [
|
||||
{ required: true, trigger: "blur", message: "请输入您的账号" },
|
||||
{ min: 2, max: 20, message: '用户账号长度必须介于 2 和 20 之间', trigger: 'blur' }
|
||||
],
|
||||
password: [
|
||||
{ required: true, trigger: "blur", message: "请输入您的密码" },
|
||||
{ min: 5, max: 20, message: "用户密码长度必须介于 5 和 20 之间", trigger: "blur" },
|
||||
{ pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }
|
||||
],
|
||||
confirmPassword: [
|
||||
{ required: true, trigger: "blur", message: "请再次输入您的密码" },
|
||||
{ required: true, validator: equalToPassword, trigger: "blur" }
|
||||
{ required: true, message: "请再次输入您的密码", trigger: "blur" },
|
||||
{
|
||||
validator: (rule, value, callback) => {
|
||||
if (this.registerForm.password !== value) {
|
||||
callback(new Error("两次输入的密码不一致"))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}, trigger: "blur"
|
||||
}
|
||||
],
|
||||
code: [{ required: true, trigger: "change", message: "请输入验证码" }]
|
||||
},
|
||||
loading: false,
|
||||
captchaEnabled: true
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item v-if="form.userId == undefined" label="用户密码" prop="password">
|
||||
<el-form-item v-if="form.userId == undefined" label="用户密码" prop="password" :rules="pwdValidator">
|
||||
<el-input v-model="form.password" placeholder="请输入用户密码" type="password" maxlength="20" show-password />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -181,9 +181,11 @@ import "@riophae/vue-treeselect/dist/vue-treeselect.css"
|
||||
import TreePanel from "@/components/TreePanel"
|
||||
import ExcelImportDialog from "@/components/ExcelImportDialog"
|
||||
import UserViewDrawer from "./view"
|
||||
import passwordRule from "@/utils/passwordRule"
|
||||
|
||||
export default {
|
||||
name: "User",
|
||||
mixins: [passwordRule],
|
||||
dicts: ['sys_normal_disable', 'sys_user_sex'],
|
||||
components: { Treeselect, TreePanel, ExcelImportDialog, UserViewDrawer },
|
||||
data() {
|
||||
@@ -248,11 +250,6 @@ export default {
|
||||
nickName: [
|
||||
{ required: true, message: "用户昵称不能为空", trigger: "blur" }
|
||||
],
|
||||
password: [
|
||||
{ required: true, message: "用户密码不能为空", trigger: "blur" },
|
||||
{ min: 5, max: 20, message: '用户密码长度必须介于 5 和 20 之间', trigger: 'blur' },
|
||||
{ pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }
|
||||
],
|
||||
email: [
|
||||
{
|
||||
type: "email",
|
||||
@@ -405,17 +402,11 @@ export default {
|
||||
},
|
||||
/** 重置密码按钮操作 */
|
||||
handleResetPwd(row) {
|
||||
this.$prompt('请输入"' + row.userName + '"的新密码', "提示", {
|
||||
this.$prompt(`请输入「${row.userName}」的新密码`, "重置密码", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
closeOnClickModal: false,
|
||||
inputPattern: /^.{5,20}$/,
|
||||
inputErrorMessage: "用户密码长度必须介于 5 和 20 之间",
|
||||
inputValidator: (value) => {
|
||||
if (/<|>|"|'|\||\\/.test(value)) {
|
||||
return "不能包含非法字符:< > \" ' \\\ |"
|
||||
}
|
||||
},
|
||||
inputValidator: this.pwdPromptValidator
|
||||
}).then(({ value }) => {
|
||||
resetUserPwd(row.userId, value).then(() => {
|
||||
this.$modal.msgSuccess("修改成功,新密码是:" + value)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<el-form ref="form" :model="user" :rules="rules" label-width="80px">
|
||||
<el-form ref="form" :model="user" :rules="formRules" label-width="80px">
|
||||
<el-form-item label="旧密码" prop="oldPassword">
|
||||
<el-input v-model="user.oldPassword" placeholder="请输入旧密码" type="password" show-password/>
|
||||
</el-form-item>
|
||||
<el-form-item label="新密码" prop="newPassword">
|
||||
<el-form-item label="新密码" prop="newPassword" :rules="infoPwdValidator">
|
||||
<el-input v-model="user.newPassword" placeholder="请输入新密码" type="password" show-password/>
|
||||
</el-form-item>
|
||||
<el-form-item label="确认密码" prop="confirmPassword">
|
||||
@@ -18,35 +18,36 @@
|
||||
|
||||
<script>
|
||||
import { updateUserPwd } from "@/api/system/user"
|
||||
import passwordRule from "@/utils/passwordRule"
|
||||
|
||||
export default {
|
||||
mixins: [passwordRule],
|
||||
data() {
|
||||
const equalToPassword = (rule, value, callback) => {
|
||||
if (this.user.newPassword !== value) {
|
||||
callback(new Error("两次输入的密码不一致"))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
return {
|
||||
user: {
|
||||
oldPassword: undefined,
|
||||
newPassword: undefined,
|
||||
confirmPassword: undefined
|
||||
}
|
||||
}
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
computed: {
|
||||
formRules() {
|
||||
return {
|
||||
oldPassword: [
|
||||
{ required: true, message: "旧密码不能为空", trigger: "blur" }
|
||||
],
|
||||
newPassword: [
|
||||
{ required: true, message: "新密码不能为空", trigger: "blur" },
|
||||
{ min: 6, max: 20, message: "长度在 6 到 20 个字符", trigger: "blur" },
|
||||
{ pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }
|
||||
],
|
||||
confirmPassword: [
|
||||
{ required: true, message: "确认密码不能为空", trigger: "blur" },
|
||||
{ required: true, validator: equalToPassword, trigger: "blur" }
|
||||
{
|
||||
validator: (rule, value, callback) => {
|
||||
if (this.user.newPassword !== value) {
|
||||
callback(new Error("两次输入的密码不一致"))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}, trigger: "blur"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,6 +553,7 @@ insert into sys_config values(5, '账号自助-是否开启用户注册功能',
|
||||
insert into sys_config values(6, '用户登录-黑名单列表', 'sys.login.blackIPList', '', 'Y', 'admin', sysdate(), '', null, '设置登录IP黑名单限制,多个匹配项以;分隔,支持匹配(*通配、网段)');
|
||||
insert into sys_config values(7, '用户管理-初始密码修改策略', 'sys.account.initPasswordModify', '1', 'Y', 'admin', sysdate(), '', null, '0:初始密码修改策略关闭,没有任何提示,1:提醒用户,如果未修改初始密码,则在登录时就会提醒修改密码对话框');
|
||||
insert into sys_config values(8, '用户管理-账号密码更新周期', 'sys.account.passwordValidateDays', '0', 'Y', 'admin', sysdate(), '', null, '密码更新周期(填写数字,数据初始化值为0不限制,若修改必须为大于0小于365的正整数),如果超过这个周期登录系统时,则在登录时就会提醒修改密码对话框');
|
||||
insert into sys_config values(9, '用户管理-密码字符范围', 'sys.account.chrtype', '0', 'Y', 'admin', sysdate(), '', null, '默认任意字符范围,0任意(密码可以输入任意字符),1数字(密码只能为0-9数字),2英文字母(密码只能为a-z和A-Z字母),3字母和数字(密码必须包含字母,数字),4字母数字和特殊字符(目前支持的特殊字符包括:~!@#$%^&*()-=_+)');
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
Reference in New Issue
Block a user