mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-11-04 10:57:10 +08:00 
			
		
		
		
	feat(system): 新增普通用户角色并调整第三方登录用户默认角色
- 原来第三方登录用户注册后默认为超管用户,是出于方便演示环境用户查看,本次有 Gitee@hagyao520 大佬反馈不安全,干脆调整此逻辑,感谢大佬提供的普通用户角色 PR
This commit is contained in:
		@@ -54,11 +54,21 @@ public class SysConstants {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public static final String SUPER_ROLE_CODE = "admin";
 | 
					    public static final String SUPER_ROLE_CODE = "admin";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 普通用户角色编码
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public static final String GENERAL_ROLE_CODE = "general";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 超管角色 ID
 | 
					     * 超管角色 ID
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static final Long SUPER_ROLE_ID = 1L;
 | 
					    public static final Long SUPER_ROLE_ID = 1L;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 普通用户角色 ID
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public static final Long GENERAL_ROLE_ID = 2L;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 全部权限标识
 | 
					     * 全部权限标识
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
@@ -74,11 +84,6 @@ public class SysConstants {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public static final String LOGOUT_URI = "/auth/logout";
 | 
					    public static final String LOGOUT_URI = "/auth/logout";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 描述类字段后缀
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public static final String DESCRIPTION_FIELD_SUFFIX = "String";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private SysConstants() {
 | 
					    private SysConstants() {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,7 +41,6 @@ import top.continew.admin.common.enums.DisEnableStatusEnum;
 | 
				
			|||||||
import top.continew.admin.common.enums.GenderEnum;
 | 
					import top.continew.admin.common.enums.GenderEnum;
 | 
				
			||||||
import top.continew.admin.system.enums.MessageTemplateEnum;
 | 
					import top.continew.admin.system.enums.MessageTemplateEnum;
 | 
				
			||||||
import top.continew.admin.system.enums.MessageTypeEnum;
 | 
					import top.continew.admin.system.enums.MessageTypeEnum;
 | 
				
			||||||
import top.continew.admin.system.model.entity.RoleDO;
 | 
					 | 
				
			||||||
import top.continew.admin.system.model.entity.user.UserDO;
 | 
					import top.continew.admin.system.model.entity.user.UserDO;
 | 
				
			||||||
import top.continew.admin.system.model.entity.user.UserSocialDO;
 | 
					import top.continew.admin.system.model.entity.user.UserSocialDO;
 | 
				
			||||||
import top.continew.admin.system.model.req.MessageReq;
 | 
					import top.continew.admin.system.model.req.MessageReq;
 | 
				
			||||||
@@ -110,8 +109,7 @@ public class SocialLoginHandler extends AbstractLoginHandler<SocialLoginReq> {
 | 
				
			|||||||
            user.setStatus(DisEnableStatusEnum.ENABLE);
 | 
					            user.setStatus(DisEnableStatusEnum.ENABLE);
 | 
				
			||||||
            userService.save(user);
 | 
					            userService.save(user);
 | 
				
			||||||
            Long userId = user.getId();
 | 
					            Long userId = user.getId();
 | 
				
			||||||
            RoleDO role = roleService.getByCode(SysConstants.SUPER_ROLE_CODE);
 | 
					            userRoleService.assignRolesToUser(Collections.singletonList(SysConstants.GENERAL_ROLE_ID), userId);
 | 
				
			||||||
            userRoleService.assignRolesToUser(Collections.singletonList(role.getId()), userId);
 | 
					 | 
				
			||||||
            userSocial = new UserSocialDO();
 | 
					            userSocial = new UserSocialDO();
 | 
				
			||||||
            userSocial.setUserId(userId);
 | 
					            userSocial.setUserId(userId);
 | 
				
			||||||
            userSocial.setSource(source);
 | 
					            userSocial.setSource(source);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -71,7 +71,7 @@ public class DemoEnvironmentJob {
 | 
				
			|||||||
    private static final Long MESSAGE_FLAG = 0L;
 | 
					    private static final Long MESSAGE_FLAG = 0L;
 | 
				
			||||||
    private static final List<Long> USER_FLAG = List
 | 
					    private static final List<Long> USER_FLAG = List
 | 
				
			||||||
        .of(1L, 547889293968801822L, 547889293968801823L, 547889293968801824L, 547889293968801825L, 547889293968801826L, 547889293968801827L, 547889293968801828L, 547889293968801829L, 547889293968801830L, 547889293968801831L);
 | 
					        .of(1L, 547889293968801822L, 547889293968801823L, 547889293968801824L, 547889293968801825L, 547889293968801826L, 547889293968801827L, 547889293968801828L, 547889293968801829L, 547889293968801830L, 547889293968801831L);
 | 
				
			||||||
    private static final List<Long> ROLE_FLAG = List.of(1L, 547888897925840927L, 547888897925840928L);
 | 
					    private static final List<Long> ROLE_FLAG = List.of(1L, 2L, 547888897925840927L, 547888897925840928L);
 | 
				
			||||||
    private static final Long DEPT_FLAG = 547887852587843611L;
 | 
					    private static final Long DEPT_FLAG = 547887852587843611L;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -156,8 +156,9 @@ INSERT INTO `sys_role`
 | 
				
			|||||||
(`id`, `name`, `code`, `data_scope`, `description`, `sort`, `is_system`, `create_user`, `create_time`)
 | 
					(`id`, `name`, `code`, `data_scope`, `description`, `sort`, `is_system`, `create_user`, `create_time`)
 | 
				
			||||||
VALUES
 | 
					VALUES
 | 
				
			||||||
(1, '系统管理员', 'admin', 1, '系统初始角色', 1, b'1', 1, NOW()),
 | 
					(1, '系统管理员', 'admin', 1, '系统初始角色', 1, b'1', 1, NOW()),
 | 
				
			||||||
(547888897925840927, '测试人员', 'tester', 5, NULL, 2, b'0', 1, NOW()),
 | 
					(2, '普通用户', 'general', 4, '系统初始角色', 2, b'1', 1, NOW()),
 | 
				
			||||||
(547888897925840928, '研发人员', 'developer', 4, NULL, 3, b'0', 1, NOW());
 | 
					(547888897925840927, '测试人员', 'tester', 5, NULL, 3, b'0', 1, NOW()),
 | 
				
			||||||
 | 
					(547888897925840928, '研发人员', 'developer', 4, NULL, 4, b'0', 1, NOW());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- 初始化默认用户:admin/admin123;test/test123
 | 
					-- 初始化默认用户:admin/admin123;test/test123
 | 
				
			||||||
INSERT INTO `sys_user`
 | 
					INSERT INTO `sys_user`
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -156,8 +156,9 @@ INSERT INTO "sys_role"
 | 
				
			|||||||
("id", "name", "code", "data_scope", "description", "sort", "is_system", "create_user", "create_time")
 | 
					("id", "name", "code", "data_scope", "description", "sort", "is_system", "create_user", "create_time")
 | 
				
			||||||
VALUES
 | 
					VALUES
 | 
				
			||||||
(1, '系统管理员', 'admin', 1, '系统初始角色', 1, true, 1, NOW()),
 | 
					(1, '系统管理员', 'admin', 1, '系统初始角色', 1, true, 1, NOW()),
 | 
				
			||||||
(547888897925840927, '测试人员', 'tester', 5, NULL, 2, false, 1, NOW()),
 | 
					(2, '普通用户', 'general', 4, '系统初始角色', 2, true, 1, NOW()),
 | 
				
			||||||
(547888897925840928, '研发人员', 'developer', 4, NULL, 3, false, 1, NOW());
 | 
					(547888897925840927, '测试人员', 'tester', 5, NULL, 3, false, 1, NOW()),
 | 
				
			||||||
 | 
					(547888897925840928, '研发人员', 'developer', 4, NULL, 4, false, 1, NOW());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- 初始化默认用户:admin/admin123;test/test123
 | 
					-- 初始化默认用户:admin/admin123;test/test123
 | 
				
			||||||
INSERT INTO "sys_user"
 | 
					INSERT INTO "sys_user"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user