mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	update 优化密码校验
This commit is contained in:
		@@ -17,6 +17,7 @@ user.username.length.valid=账户长度必须在{min}到{max}个字符之间
 | 
			
		||||
user.password.not.blank=用户密码不能为空
 | 
			
		||||
user.password.length.valid=用户密码长度必须在{min}到{max}个字符之间
 | 
			
		||||
user.password.not.valid=* 5-50个字符
 | 
			
		||||
user.password.format.valid=密码必须包含大写字母、小写字母、数字和特殊字符
 | 
			
		||||
user.email.not.valid=邮箱格式错误
 | 
			
		||||
user.email.not.blank=邮箱不能为空
 | 
			
		||||
user.phonenumber.not.blank=用户手机号不能为空
 | 
			
		||||
 
 | 
			
		||||
@@ -17,6 +17,7 @@ user.username.length.valid=Account length must be between {min} and {max} charac
 | 
			
		||||
user.password.not.blank=Password cannot be empty
 | 
			
		||||
user.password.length.valid=Password length must be between {min} and {max} characters
 | 
			
		||||
user.password.not.valid=* 5-50 characters
 | 
			
		||||
user.password.format.valid=Password must contain uppercase, lowercase, digit, and special character
 | 
			
		||||
user.email.not.valid=Mailbox format error
 | 
			
		||||
user.email.not.blank=Mailbox cannot be blank
 | 
			
		||||
user.phonenumber.not.blank=Phone number cannot be blank
 | 
			
		||||
@@ -55,7 +56,7 @@ social.source.not.blank=Social login platform [source] cannot be blank
 | 
			
		||||
social.code.not.blank=Social login platform [code] cannot be blank
 | 
			
		||||
social.state.not.blank=Social login platform [state] cannot be blank
 | 
			
		||||
##租户
 | 
			
		||||
tenant.number.not.blank=Tenant number cannot be blank
 | 
			
		||||
tenant.number.not.blank=Password must be at least 8 characters long and include uppercase letters, lowercase letters, numbers, and special characters.
 | 
			
		||||
tenant.not.exists=Sorry, your tenant does not exist. Please contact the administrator
 | 
			
		||||
tenant.blocked=Sorry, your tenant is disabled. Please contact the administrator
 | 
			
		||||
tenant.expired=Sorry, your tenant has expired. Please contact the administrator.
 | 
			
		||||
 
 | 
			
		||||
@@ -17,6 +17,7 @@ user.username.length.valid=账户长度必须在{min}到{max}个字符之间
 | 
			
		||||
user.password.not.blank=用户密码不能为空
 | 
			
		||||
user.password.length.valid=用户密码长度必须在{min}到{max}个字符之间
 | 
			
		||||
user.password.not.valid=* 5-50个字符
 | 
			
		||||
user.password.format.valid=密码必须包含大写字母、小写字母、数字和特殊字符
 | 
			
		||||
user.email.not.valid=邮箱格式错误
 | 
			
		||||
user.email.not.blank=邮箱不能为空
 | 
			
		||||
user.phonenumber.not.blank=用户手机号不能为空
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,7 @@ public class PasswordLoginBody extends LoginBody {
 | 
			
		||||
     */
 | 
			
		||||
    @NotBlank(message = "{user.password.not.blank}")
 | 
			
		||||
    @Length(min = 5, max = 30, message = "{user.password.length.valid}")
 | 
			
		||||
//    @Pattern(regexp = RegexConstants.PASSWORD, message = "{user.password.format.valid}")
 | 
			
		||||
    private String password;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -26,8 +26,12 @@ public class RegisterBody extends LoginBody {
 | 
			
		||||
     */
 | 
			
		||||
    @NotBlank(message = "{user.password.not.blank}")
 | 
			
		||||
    @Length(min = 5, max = 30, message = "{user.password.length.valid}")
 | 
			
		||||
//    @Pattern(regexp = RegexConstants.PASSWORD, message = "{user.password.format.valid}")
 | 
			
		||||
    private String password;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 用户类型
 | 
			
		||||
     */
 | 
			
		||||
    private String userType;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,17 +1,17 @@
 | 
			
		||||
package org.dromara.system.domain.bo;
 | 
			
		||||
 | 
			
		||||
import org.dromara.common.core.validate.AddGroup;
 | 
			
		||||
import org.dromara.common.core.validate.EditGroup;
 | 
			
		||||
import org.dromara.system.domain.SysTenant;
 | 
			
		||||
import io.github.linpeilie.annotations.AutoMapper;
 | 
			
		||||
import jakarta.validation.constraints.NotBlank;
 | 
			
		||||
import jakarta.validation.constraints.NotNull;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.EqualsAndHashCode;
 | 
			
		||||
import jakarta.validation.constraints.*;
 | 
			
		||||
import org.dromara.common.core.validate.AddGroup;
 | 
			
		||||
import org.dromara.common.core.validate.EditGroup;
 | 
			
		||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
 | 
			
		||||
import org.dromara.system.domain.SysTenant;
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
 | 
			
		||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 租户业务对象 sys_tenant
 | 
			
		||||
 *
 | 
			
		||||
@@ -62,6 +62,7 @@ public class SysTenantBo extends BaseEntity {
 | 
			
		||||
     * 密码(创建系统用户)
 | 
			
		||||
     */
 | 
			
		||||
    @NotBlank(message = "密码不能为空", groups = { AddGroup.class })
 | 
			
		||||
//    @Pattern(regexp = RegexConstants.PASSWORD, message = "{user.password.format.valid}")
 | 
			
		||||
    private String password;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -1,16 +1,13 @@
 | 
			
		||||
package org.dromara.system.mapper;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.collection.CollUtil;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
			
		||||
import org.apache.ibatis.annotations.Param;
 | 
			
		||||
import org.dromara.common.core.exception.ServiceException;
 | 
			
		||||
import org.dromara.common.mybatis.annotation.DataColumn;
 | 
			
		||||
import org.dromara.common.mybatis.annotation.DataPermission;
 | 
			
		||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
 | 
			
		||||
import org.dromara.common.satoken.utils.LoginHelper;
 | 
			
		||||
import org.dromara.system.domain.SysRole;
 | 
			
		||||
import org.dromara.system.domain.vo.SysRoleVo;
 | 
			
		||||
 | 
			
		||||
@@ -78,21 +75,6 @@ public interface SysRoleMapper extends BaseMapperPlus<SysRole, SysRoleVo> {
 | 
			
		||||
        return this.selectCount(new LambdaQueryWrapper<SysRole>().in(SysRole::getRoleId, roleIds));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 校验角色是否有数据权限
 | 
			
		||||
     *
 | 
			
		||||
     * @param roleIds 角色ID列表(支持传单个ID)
 | 
			
		||||
     */
 | 
			
		||||
    default void checkRoleDataScope(List<Long> roleIds) {
 | 
			
		||||
        if (CollUtil.isEmpty(roleIds) || LoginHelper.isSuperAdmin()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        long count = this.selectRoleCount(roleIds);
 | 
			
		||||
        if (count != roleIds.size()) {
 | 
			
		||||
            throw new ServiceException("没有权限访问部分角色数据!");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据角色ID查询角色信息
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -118,6 +118,13 @@ public interface ISysRoleService {
 | 
			
		||||
     */
 | 
			
		||||
    void checkRoleDataScope(Long roleId);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 校验角色是否有数据权限
 | 
			
		||||
     *
 | 
			
		||||
     * @param roleIds 角色ID列表(支持传单个ID)
 | 
			
		||||
     */
 | 
			
		||||
    void checkRoleDataScope(List<Long> roleIds);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 通过角色ID查询角色使用数量
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -254,7 +254,23 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
 | 
			
		||||
        if (ObjectUtil.isNull(roleId)) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        baseMapper.checkRoleDataScope(Collections.singletonList(roleId));
 | 
			
		||||
        this.checkRoleDataScope(Collections.singletonList(roleId));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 校验角色是否有数据权限
 | 
			
		||||
     *
 | 
			
		||||
     * @param roleIds 角色ID列表(支持传单个ID)
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void checkRoleDataScope(List<Long> roleIds) {
 | 
			
		||||
        if (CollUtil.isEmpty(roleIds) || LoginHelper.isSuperAdmin()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        long count = baseMapper.selectRoleCount(roleIds);
 | 
			
		||||
        if (count != roleIds.size()) {
 | 
			
		||||
            throw new ServiceException("没有权限访问部分角色数据!");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -411,8 +427,8 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
 | 
			
		||||
    @Override
 | 
			
		||||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
    public int deleteRoleByIds(List<Long> roleIds) {
 | 
			
		||||
        this.checkRoleDataScope(roleIds);
 | 
			
		||||
        List<SysRole> roles = baseMapper.selectByIds(roleIds);
 | 
			
		||||
        baseMapper.checkRoleDataScope(roleIds);
 | 
			
		||||
        for (SysRole role : roles) {
 | 
			
		||||
            checkRoleAllowed(BeanUtil.toBean(role, SysRoleBo.class));
 | 
			
		||||
            if (countUserRoleByRoleId(role.getRoleId()) > 0) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user