Commit 4a23a696f421331990974d30f69d95700aeb9fe4
1 parent
e8e6024a
1. 修复“登陆”=》“登录”
2. 增加社交平台的绑定与解绑
Showing
56 changed files
with
329 additions
and
149 deletions
README.md
| @@ -127,11 +127,11 @@ | @@ -127,11 +127,11 @@ | ||
| 127 | 127 | ||
| 128 | | 模块 | biu | biu | biu | | 128 | | 模块 | biu | biu | biu | |
| 129 | | --- | --- | --- | --- | | 129 | | --- | --- | --- | --- | |
| 130 | -| 登陆 & 首页 |  |  |  | | 130 | +| 登录 & 首页 |  |  |  | |
| 131 | | 用户 |  |  | - | | 131 | | 用户 |  |  | - | |
| 132 | | 部门 & 岗位 |  |  | - | | 132 | | 部门 & 岗位 |  |  | - | |
| 133 | | 菜单 & 角色 |  |  | - | | 133 | | 菜单 & 角色 |  |  | - | |
| 134 | -| 审计日志 |  |  | - | | 134 | +| 审计日志 |  |  | - | |
| 135 | | 短信 |  |  |  | | 135 | | 短信 |  |  |  | |
| 136 | | 字典 |  |  | - | | 136 | | 字典 |  |  | - | |
| 137 | | 错误码 & 通知 |  |  | - | | 137 | | 错误码 & 通知 |  |  | - | |
sql/ruoyi-vue-pro.sql
| @@ -299,12 +299,12 @@ INSERT INTO `sys_dict_data` VALUES (35, 2, '指定部门数据权限', '2', 'sys | @@ -299,12 +299,12 @@ INSERT INTO `sys_dict_data` VALUES (35, 2, '指定部门数据权限', '2', 'sys | ||
| 299 | INSERT INTO `sys_dict_data` VALUES (36, 3, '本部门数据权限', '3', 'sys_data_scope', 0, '本部门数据权限', 'admin', '2021-01-05 17:03:48', '', '2021-01-06 19:38:29', b'0'); | 299 | INSERT INTO `sys_dict_data` VALUES (36, 3, '本部门数据权限', '3', 'sys_data_scope', 0, '本部门数据权限', 'admin', '2021-01-05 17:03:48', '', '2021-01-06 19:38:29', b'0'); |
| 300 | INSERT INTO `sys_dict_data` VALUES (37, 4, '本部门及以下数据权限', '4', 'sys_data_scope', 0, '本部门及以下数据权限', 'admin', '2021-01-05 17:03:48', '', '2021-01-06 19:38:32', b'0'); | 300 | INSERT INTO `sys_dict_data` VALUES (37, 4, '本部门及以下数据权限', '4', 'sys_data_scope', 0, '本部门及以下数据权限', 'admin', '2021-01-05 17:03:48', '', '2021-01-06 19:38:32', b'0'); |
| 301 | INSERT INTO `sys_dict_data` VALUES (38, 5, '仅本人数据权限', '5', 'sys_data_scope', 0, '仅本人数据权限', 'admin', '2021-01-05 17:03:48', '', '2021-01-06 19:38:38', b'0'); | 301 | INSERT INTO `sys_dict_data` VALUES (38, 5, '仅本人数据权限', '5', 'sys_data_scope', 0, '仅本人数据权限', 'admin', '2021-01-05 17:03:48', '', '2021-01-06 19:38:38', b'0'); |
| 302 | -INSERT INTO `sys_dict_data` VALUES (39, 0, '成功', '0', 'sys_login_result', 0, '登陆结果 - 成功', '', '2021-01-18 06:17:36', '', '2021-01-18 06:17:36', b'0'); | ||
| 303 | -INSERT INTO `sys_dict_data` VALUES (40, 10, '账号或密码不正确', '10', 'sys_login_result', 0, '登陆结果 - 账号或密码不正确', '', '2021-01-18 06:17:54', '', '2021-01-18 06:17:54', b'0'); | ||
| 304 | -INSERT INTO `sys_dict_data` VALUES (41, 20, '用户被禁用', '20', 'sys_login_result', 0, '登陆结果 - 用户被禁用', '', '2021-01-18 06:17:54', '', '2021-01-18 06:19:02', b'0'); | ||
| 305 | -INSERT INTO `sys_dict_data` VALUES (42, 30, '验证码不存在', '30', 'sys_login_result', 0, '登陆结果 - 验证码不存在', '', '2021-01-18 06:17:54', '', '2021-01-18 06:19:24', b'0'); | ||
| 306 | -INSERT INTO `sys_dict_data` VALUES (43, 31, '验证码不正确', '31', 'sys_login_result', 0, '登陆结果 - 验证码不正确', '', '2021-01-18 06:17:54', '', '2021-01-18 06:19:33', b'0'); | ||
| 307 | -INSERT INTO `sys_dict_data` VALUES (44, 100, '未知异常', '100', 'sys_login_result', 0, '登陆结果 - 未知异常', '', '2021-01-18 06:17:54', '', '2021-01-18 06:19:57', b'0'); | 302 | +INSERT INTO `sys_dict_data` VALUES (39, 0, '成功', '0', 'sys_login_result', 0, '登录结果 - 成功', '', '2021-01-18 06:17:36', '', '2021-01-18 06:17:36', b'0'); |
| 303 | +INSERT INTO `sys_dict_data` VALUES (40, 10, '账号或密码不正确', '10', 'sys_login_result', 0, '登录结果 - 账号或密码不正确', '', '2021-01-18 06:17:54', '', '2021-01-18 06:17:54', b'0'); | ||
| 304 | +INSERT INTO `sys_dict_data` VALUES (41, 20, '用户被禁用', '20', 'sys_login_result', 0, '登录结果 - 用户被禁用', '', '2021-01-18 06:17:54', '', '2021-01-18 06:19:02', b'0'); | ||
| 305 | +INSERT INTO `sys_dict_data` VALUES (42, 30, '验证码不存在', '30', 'sys_login_result', 0, '登录结果 - 验证码不存在', '', '2021-01-18 06:17:54', '', '2021-01-18 06:19:24', b'0'); | ||
| 306 | +INSERT INTO `sys_dict_data` VALUES (43, 31, '验证码不正确', '31', 'sys_login_result', 0, '登录结果 - 验证码不正确', '', '2021-01-18 06:17:54', '', '2021-01-18 06:19:33', b'0'); | ||
| 307 | +INSERT INTO `sys_dict_data` VALUES (44, 100, '未知异常', '100', 'sys_login_result', 0, '登录结果 - 未知异常', '', '2021-01-18 06:17:54', '', '2021-01-18 06:19:57', b'0'); | ||
| 308 | INSERT INTO `sys_dict_data` VALUES (45, 1, '是', 'true', 'sys_boolean_string', 0, 'Boolean 是否类型 - 是', '', '2021-01-19 03:20:55', '', '2021-01-19 03:21:08', b'0'); | 308 | INSERT INTO `sys_dict_data` VALUES (45, 1, '是', 'true', 'sys_boolean_string', 0, 'Boolean 是否类型 - 是', '', '2021-01-19 03:20:55', '', '2021-01-19 03:21:08', b'0'); |
| 309 | INSERT INTO `sys_dict_data` VALUES (46, 1, '否', 'false', 'sys_boolean_string', 0, 'Boolean 是否类型 - 否', '', '2021-01-19 03:20:55', '', '2021-01-19 03:21:39', b'0'); | 309 | INSERT INTO `sys_dict_data` VALUES (46, 1, '否', 'false', 'sys_boolean_string', 0, 'Boolean 是否类型 - 否', '', '2021-01-19 03:20:55', '', '2021-01-19 03:21:39', b'0'); |
| 310 | INSERT INTO `sys_dict_data` VALUES (47, 1, '永不超时', '1', 'inf_redis_timeout_type', 0, 'Redis 未设置超时的情况', '', '2021-01-26 00:53:17', '', '2021-01-26 00:53:17', b'0'); | 310 | INSERT INTO `sys_dict_data` VALUES (47, 1, '永不超时', '1', 'inf_redis_timeout_type', 0, 'Redis 未设置超时的情况', '', '2021-01-26 00:53:17', '', '2021-01-26 00:53:17', b'0'); |
| @@ -380,7 +380,7 @@ INSERT INTO `sys_dict_type` VALUES (8, '通知状态', 'sys_notice_status', 0, N | @@ -380,7 +380,7 @@ INSERT INTO `sys_dict_type` VALUES (8, '通知状态', 'sys_notice_status', 0, N | ||
| 380 | INSERT INTO `sys_dict_type` VALUES (9, '操作类型', 'sys_oper_type', 0, NULL, 'admin', '2021-01-05 17:03:48', '', '2021-01-05 17:03:48', b'0'); | 380 | INSERT INTO `sys_dict_type` VALUES (9, '操作类型', 'sys_oper_type', 0, NULL, 'admin', '2021-01-05 17:03:48', '', '2021-01-05 17:03:48', b'0'); |
| 381 | INSERT INTO `sys_dict_type` VALUES (10, '系统状态', 'sys_common_status', 0, NULL, 'admin', '2021-01-05 17:03:48', '', '2021-01-05 17:03:48', b'0'); | 381 | INSERT INTO `sys_dict_type` VALUES (10, '系统状态', 'sys_common_status', 0, NULL, 'admin', '2021-01-05 17:03:48', '', '2021-01-05 17:03:48', b'0'); |
| 382 | INSERT INTO `sys_dict_type` VALUES (11, 'Boolean 是否类型', 'sys_boolean_string', 0, 'boolean 转是否', '', '2021-01-19 03:20:08', '', '2021-01-19 03:20:08', b'0'); | 382 | INSERT INTO `sys_dict_type` VALUES (11, 'Boolean 是否类型', 'sys_boolean_string', 0, 'boolean 转是否', '', '2021-01-19 03:20:08', '', '2021-01-19 03:20:08', b'0'); |
| 383 | -INSERT INTO `sys_dict_type` VALUES (104, '登陆结果', 'sys_login_result', 0, '登陆结果', '', '2021-01-18 06:17:11', '', '2021-01-18 06:17:11', b'0'); | 383 | +INSERT INTO `sys_dict_type` VALUES (104, '登录结果', 'sys_login_result', 0, '登录结果', '', '2021-01-18 06:17:11', '', '2021-01-18 06:17:11', b'0'); |
| 384 | INSERT INTO `sys_dict_type` VALUES (105, 'Redis 超时类型', 'inf_redis_timeout_type', 0, 'RedisKeyDefine.TimeoutTypeEnum', '', '2021-01-26 00:52:50', '', '2021-01-26 00:52:50', b'0'); | 384 | INSERT INTO `sys_dict_type` VALUES (105, 'Redis 超时类型', 'inf_redis_timeout_type', 0, 'RedisKeyDefine.TimeoutTypeEnum', '', '2021-01-26 00:52:50', '', '2021-01-26 00:52:50', b'0'); |
| 385 | INSERT INTO `sys_dict_type` VALUES (106, '代码生成模板类型', 'tool_codegen_template_type', 0, NULL, '', '2021-02-05 07:08:06', '', '2021-02-05 07:08:06', b'0'); | 385 | INSERT INTO `sys_dict_type` VALUES (106, '代码生成模板类型', 'tool_codegen_template_type', 0, NULL, '', '2021-02-05 07:08:06', '', '2021-02-05 07:08:06', b'0'); |
| 386 | INSERT INTO `sys_dict_type` VALUES (107, '定时任务状态', 'inf_job_status', 0, NULL, '', '2021-02-07 07:44:16', '', '2021-02-07 07:44:16', b'0'); | 386 | INSERT INTO `sys_dict_type` VALUES (107, '定时任务状态', 'inf_job_status', 0, NULL, '', '2021-02-07 07:44:16', '', '2021-02-07 07:44:16', b'0'); |
| @@ -392,7 +392,7 @@ INSERT INTO `sys_dict_type` VALUES (112, '短信模板的类型', 'sys_sms_templ | @@ -392,7 +392,7 @@ INSERT INTO `sys_dict_type` VALUES (112, '短信模板的类型', 'sys_sms_templ | ||
| 392 | INSERT INTO `sys_dict_type` VALUES (113, '短信发送状态', 'sys_sms_send_status', 0, NULL, '1', '2021-04-11 20:18:03', '1', '2021-04-11 09:30:02', b'0'); | 392 | INSERT INTO `sys_dict_type` VALUES (113, '短信发送状态', 'sys_sms_send_status', 0, NULL, '1', '2021-04-11 20:18:03', '1', '2021-04-11 09:30:02', b'0'); |
| 393 | INSERT INTO `sys_dict_type` VALUES (114, '短信接收状态', 'sys_sms_receive_status', 0, NULL, '1', '2021-04-11 20:27:14', '1', '2021-04-11 20:27:14', b'0'); | 393 | INSERT INTO `sys_dict_type` VALUES (114, '短信接收状态', 'sys_sms_receive_status', 0, NULL, '1', '2021-04-11 20:27:14', '1', '2021-04-11 20:27:14', b'0'); |
| 394 | INSERT INTO `sys_dict_type` VALUES (115, '错误码的类型', 'sys_error_code_type', 0, NULL, '1', '2021-04-21 00:06:30', '1', '2021-04-13 22:07:12', b'0'); | 394 | INSERT INTO `sys_dict_type` VALUES (115, '错误码的类型', 'sys_error_code_type', 0, NULL, '1', '2021-04-21 00:06:30', '1', '2021-04-13 22:07:12', b'0'); |
| 395 | -INSERT INTO `sys_dict_type` VALUES (116, '登陆日志的类型', 'sys_login_type', 0, '登陆日志的类型', '1', '2021-10-06 00:50:46', '1', '2021-10-06 00:50:46', b'0'); | 395 | +INSERT INTO `sys_dict_type` VALUES (116, '登录日志的类型', 'sys_login_type', 0, '登录日志的类型', '1', '2021-10-06 00:50:46', '1', '2021-10-06 00:50:46', b'0'); |
| 396 | COMMIT; | 396 | COMMIT; |
| 397 | 397 | ||
| 398 | -- ---------------------------- | 398 | -- ---------------------------- |
| @@ -511,7 +511,7 @@ CREATE TABLE `sys_login_log` ( | @@ -511,7 +511,7 @@ CREATE TABLE `sys_login_log` ( | ||
| 511 | `user_id` bigint NOT NULL DEFAULT '0' COMMENT '用户编号', | 511 | `user_id` bigint NOT NULL DEFAULT '0' COMMENT '用户编号', |
| 512 | `user_type` tinyint NOT NULL DEFAULT '0' COMMENT '用户类型', | 512 | `user_type` tinyint NOT NULL DEFAULT '0' COMMENT '用户类型', |
| 513 | `username` varchar(50) NOT NULL DEFAULT '' COMMENT '用户账号', | 513 | `username` varchar(50) NOT NULL DEFAULT '' COMMENT '用户账号', |
| 514 | - `result` tinyint NOT NULL COMMENT '登陆结果', | 514 | + `result` tinyint NOT NULL COMMENT '登录结果', |
| 515 | `user_ip` varchar(50) NOT NULL COMMENT '用户 IP', | 515 | `user_ip` varchar(50) NOT NULL COMMENT '用户 IP', |
| 516 | `user_agent` varchar(512) NOT NULL COMMENT '浏览器 UA', | 516 | `user_agent` varchar(512) NOT NULL COMMENT '浏览器 UA', |
| 517 | `creator` varchar(64) DEFAULT '' COMMENT '创建者', | 517 | `creator` varchar(64) DEFAULT '' COMMENT '创建者', |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/SysAuthController.java
| @@ -70,7 +70,7 @@ public class SysAuthController { | @@ -70,7 +70,7 @@ public class SysAuthController { | ||
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | @GetMapping("/get-permission-info") | 72 | @GetMapping("/get-permission-info") |
| 73 | - @ApiOperation("获取登陆用户的权限信息") | 73 | + @ApiOperation("获取登录用户的权限信息") |
| 74 | public CommonResult<SysAuthPermissionInfoRespVO> getPermissionInfo() { | 74 | public CommonResult<SysAuthPermissionInfoRespVO> getPermissionInfo() { |
| 75 | // 获得用户信息 | 75 | // 获得用户信息 |
| 76 | SysUserDO user = userService.getUser(getLoginUserId()); | 76 | SysUserDO user = userService.getUser(getLoginUserId()); |
| @@ -81,7 +81,7 @@ public class SysAuthController { | @@ -81,7 +81,7 @@ public class SysAuthController { | ||
| 81 | List<SysRoleDO> roleList = roleService.getRolesFromCache(getLoginUserRoleIds()); | 81 | List<SysRoleDO> roleList = roleService.getRolesFromCache(getLoginUserRoleIds()); |
| 82 | // 获得菜单列表 | 82 | // 获得菜单列表 |
| 83 | List<SysMenuDO> menuList = permissionService.getRoleMenusFromCache( | 83 | List<SysMenuDO> menuList = permissionService.getRoleMenusFromCache( |
| 84 | - getLoginUserRoleIds(), // 注意,基于登陆的角色,因为后续的权限判断也是基于它 | 84 | + getLoginUserRoleIds(), // 注意,基于登录的角色,因为后续的权限判断也是基于它 |
| 85 | SetUtils.asSet(MenuTypeEnum.DIR.getType(), MenuTypeEnum.MENU.getType(), MenuTypeEnum.BUTTON.getType()), | 85 | SetUtils.asSet(MenuTypeEnum.DIR.getType(), MenuTypeEnum.MENU.getType(), MenuTypeEnum.BUTTON.getType()), |
| 86 | SetUtils.asSet(CommonStatusEnum.ENABLE.getStatus())); | 86 | SetUtils.asSet(CommonStatusEnum.ENABLE.getStatus())); |
| 87 | // 拼接结果返回 | 87 | // 拼接结果返回 |
| @@ -89,32 +89,32 @@ public class SysAuthController { | @@ -89,32 +89,32 @@ public class SysAuthController { | ||
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | @GetMapping("list-menus") | 91 | @GetMapping("list-menus") |
| 92 | - @ApiOperation("获得登陆用户的菜单列表") | 92 | + @ApiOperation("获得登录用户的菜单列表") |
| 93 | public CommonResult<List<SysAuthMenuRespVO>> getMenus() { | 93 | public CommonResult<List<SysAuthMenuRespVO>> getMenus() { |
| 94 | // 获得用户拥有的菜单列表 | 94 | // 获得用户拥有的菜单列表 |
| 95 | List<SysMenuDO> menuList = permissionService.getRoleMenusFromCache( | 95 | List<SysMenuDO> menuList = permissionService.getRoleMenusFromCache( |
| 96 | - getLoginUserRoleIds(), // 注意,基于登陆的角色,因为后续的权限判断也是基于它 | 96 | + getLoginUserRoleIds(), // 注意,基于登录的角色,因为后续的权限判断也是基于它 |
| 97 | SetUtils.asSet(MenuTypeEnum.DIR.getType(), MenuTypeEnum.MENU.getType()), // 只要目录和菜单类型 | 97 | SetUtils.asSet(MenuTypeEnum.DIR.getType(), MenuTypeEnum.MENU.getType()), // 只要目录和菜单类型 |
| 98 | SetUtils.asSet(CommonStatusEnum.ENABLE.getStatus())); // 只要开启的 | 98 | SetUtils.asSet(CommonStatusEnum.ENABLE.getStatus())); // 只要开启的 |
| 99 | // 转换成 Tree 结构返回 | 99 | // 转换成 Tree 结构返回 |
| 100 | return success(SysAuthConvert.INSTANCE.buildMenuTree(menuList)); | 100 | return success(SysAuthConvert.INSTANCE.buildMenuTree(menuList)); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | - // ========== 社交登陆相关 ========== | 103 | + // ========== 社交登录相关 ========== |
| 104 | 104 | ||
| 105 | - @GetMapping("/social-login-redirect") | ||
| 106 | - @ApiOperation("社交登陆的跳转") | 105 | + @GetMapping("/social-auth-redirect") |
| 106 | + @ApiOperation("社交授权的跳转") | ||
| 107 | @ApiImplicitParams({ | 107 | @ApiImplicitParams({ |
| 108 | @ApiImplicitParam(name = "type", value = "社交类型", required = true, dataTypeClass = Integer.class), | 108 | @ApiImplicitParam(name = "type", value = "社交类型", required = true, dataTypeClass = Integer.class), |
| 109 | @ApiImplicitParam(name = "redirectUri", value = "回调路径", dataTypeClass = String.class) | 109 | @ApiImplicitParam(name = "redirectUri", value = "回调路径", dataTypeClass = String.class) |
| 110 | }) | 110 | }) |
| 111 | - public CommonResult<String> socialLoginRedirect(@RequestParam("type") Integer type, | 111 | + public CommonResult<String> socialAuthRedirect(@RequestParam("type") Integer type, |
| 112 | @RequestParam("redirectUri") String redirectUri) { | 112 | @RequestParam("redirectUri") String redirectUri) { |
| 113 | return CommonResult.success(socialService.getAuthorizeUrl(type, redirectUri)); | 113 | return CommonResult.success(socialService.getAuthorizeUrl(type, redirectUri)); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | @PostMapping("/social-login") | 116 | @PostMapping("/social-login") |
| 117 | - @ApiOperation("社交登陆,使用 code 授权码") | 117 | + @ApiOperation("社交登录,使用 code 授权码") |
| 118 | @OperateLog(enable = false) // 避免 Post 请求被记录操作日志 | 118 | @OperateLog(enable = false) // 避免 Post 请求被记录操作日志 |
| 119 | public CommonResult<SysAuthLoginRespVO> socialLogin(@RequestBody @Valid SysAuthSocialLoginReqVO reqVO) { | 119 | public CommonResult<SysAuthLoginRespVO> socialLogin(@RequestBody @Valid SysAuthSocialLoginReqVO reqVO) { |
| 120 | String token = authService.socialLogin(reqVO, getClientIP(), getUserAgent()); | 120 | String token = authService.socialLogin(reqVO, getClientIP(), getUserAgent()); |
| @@ -123,7 +123,7 @@ public class SysAuthController { | @@ -123,7 +123,7 @@ public class SysAuthController { | ||
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | @PostMapping("/social-login2") | 125 | @PostMapping("/social-login2") |
| 126 | - @ApiOperation("社交登陆,使用 code 授权码 + 账号密码") | 126 | + @ApiOperation("社交登录,使用 code 授权码 + 账号密码") |
| 127 | @OperateLog(enable = false) // 避免 Post 请求被记录操作日志 | 127 | @OperateLog(enable = false) // 避免 Post 请求被记录操作日志 |
| 128 | public CommonResult<SysAuthLoginRespVO> socialLogin2(@RequestBody @Valid SysAuthSocialLogin2ReqVO reqVO) { | 128 | public CommonResult<SysAuthLoginRespVO> socialLogin2(@RequestBody @Valid SysAuthSocialLogin2ReqVO reqVO) { |
| 129 | String token = authService.socialLogin2(reqVO, getClientIP(), getUserAgent()); | 129 | String token = authService.socialLogin2(reqVO, getClientIP(), getUserAgent()); |
| @@ -131,4 +131,18 @@ public class SysAuthController { | @@ -131,4 +131,18 @@ public class SysAuthController { | ||
| 131 | return success(SysAuthLoginRespVO.builder().token(token).build()); | 131 | return success(SysAuthLoginRespVO.builder().token(token).build()); |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | + @PostMapping("/social-bind") | ||
| 135 | + @ApiOperation("社交绑定,使用 code 授权码") | ||
| 136 | + public CommonResult<Boolean> socialBind(@RequestBody @Valid SysAuthSocialBindReqVO reqVO) { | ||
| 137 | + authService.socialBind(getLoginUserId(), reqVO); | ||
| 138 | + return CommonResult.success(true); | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + @DeleteMapping("/social-unbind") | ||
| 142 | + @ApiOperation("取消社交绑定") | ||
| 143 | + public CommonResult<Boolean> socialUnbind(@RequestBody SysAuthSocialUnbindReqVO reqVO) { | ||
| 144 | + socialService.unbindSocialUser(getLoginUserId(), reqVO.getType(), reqVO.getUnionId()); | ||
| 145 | + return CommonResult.success(true); | ||
| 146 | + } | ||
| 147 | + | ||
| 134 | } | 148 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/vo/auth/SysAuthLoginReqVO.java
| @@ -11,7 +11,7 @@ import org.hibernate.validator.constraints.Length; | @@ -11,7 +11,7 @@ import org.hibernate.validator.constraints.Length; | ||
| 11 | import javax.validation.constraints.NotEmpty; | 11 | import javax.validation.constraints.NotEmpty; |
| 12 | import javax.validation.constraints.Pattern; | 12 | import javax.validation.constraints.Pattern; |
| 13 | 13 | ||
| 14 | -@ApiModel("账号密码登陆 Request VO") | 14 | +@ApiModel("账号密码登录 Request VO") |
| 15 | @Data | 15 | @Data |
| 16 | @NoArgsConstructor | 16 | @NoArgsConstructor |
| 17 | @AllArgsConstructor | 17 | @AllArgsConstructor |
| @@ -19,7 +19,7 @@ import javax.validation.constraints.Pattern; | @@ -19,7 +19,7 @@ import javax.validation.constraints.Pattern; | ||
| 19 | public class SysAuthLoginReqVO { | 19 | public class SysAuthLoginReqVO { |
| 20 | 20 | ||
| 21 | @ApiModelProperty(value = "账号", required = true, example = "yudaoyuanma") | 21 | @ApiModelProperty(value = "账号", required = true, example = "yudaoyuanma") |
| 22 | - @NotEmpty(message = "登陆账号不能为空") | 22 | + @NotEmpty(message = "登录账号不能为空") |
| 23 | @Length(min = 4, max = 16, message = "账号长度为 4-16 位") | 23 | @Length(min = 4, max = 16, message = "账号长度为 4-16 位") |
| 24 | @Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母") | 24 | @Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母") |
| 25 | private String username; | 25 | private String username; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/vo/auth/SysAuthLoginRespVO.java
| @@ -7,7 +7,7 @@ import lombok.Builder; | @@ -7,7 +7,7 @@ import lombok.Builder; | ||
| 7 | import lombok.Data; | 7 | import lombok.Data; |
| 8 | import lombok.NoArgsConstructor; | 8 | import lombok.NoArgsConstructor; |
| 9 | 9 | ||
| 10 | -@ApiModel("账号密码登陆 Response VO") | 10 | +@ApiModel("账号密码登录 Response VO") |
| 11 | @Data | 11 | @Data |
| 12 | @NoArgsConstructor | 12 | @NoArgsConstructor |
| 13 | @AllArgsConstructor | 13 | @AllArgsConstructor |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/vo/auth/SysAuthMenuRespVO.java
| @@ -9,7 +9,7 @@ import lombok.NoArgsConstructor; | @@ -9,7 +9,7 @@ import lombok.NoArgsConstructor; | ||
| 9 | 9 | ||
| 10 | import java.util.List; | 10 | import java.util.List; |
| 11 | 11 | ||
| 12 | -@ApiModel("登陆用户的菜单信息 Response VO") | 12 | +@ApiModel("登录用户的菜单信息 Response VO") |
| 13 | @Data | 13 | @Data |
| 14 | @NoArgsConstructor | 14 | @NoArgsConstructor |
| 15 | @AllArgsConstructor | 15 | @AllArgsConstructor |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/vo/auth/SysAuthPermissionInfoRespVO.java
| @@ -9,7 +9,7 @@ import lombok.NoArgsConstructor; | @@ -9,7 +9,7 @@ import lombok.NoArgsConstructor; | ||
| 9 | 9 | ||
| 10 | import java.util.Set; | 10 | import java.util.Set; |
| 11 | 11 | ||
| 12 | -@ApiModel(value = "登陆用户的权限信息 Response VO", description = "额外包括用户信息和角色列表") | 12 | +@ApiModel(value = "登录用户的权限信息 Response VO", description = "额外包括用户信息和角色列表") |
| 13 | @Data | 13 | @Data |
| 14 | @NoArgsConstructor | 14 | @NoArgsConstructor |
| 15 | @AllArgsConstructor | 15 | @AllArgsConstructor |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/vo/auth/SysAuthSocialBindReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.adminserver.modules.system.enums.user.SysSocialTypeEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 5 | +import io.swagger.annotations.ApiModel; | ||
| 6 | +import io.swagger.annotations.ApiModelProperty; | ||
| 7 | +import lombok.AllArgsConstructor; | ||
| 8 | +import lombok.Builder; | ||
| 9 | +import lombok.Data; | ||
| 10 | +import lombok.NoArgsConstructor; | ||
| 11 | + | ||
| 12 | +import javax.validation.constraints.NotEmpty; | ||
| 13 | +import javax.validation.constraints.NotNull; | ||
| 14 | + | ||
| 15 | +@ApiModel("社交绑定 Request VO,使用 code 授权码") | ||
| 16 | +@Data | ||
| 17 | +@NoArgsConstructor | ||
| 18 | +@AllArgsConstructor | ||
| 19 | +@Builder | ||
| 20 | +public class SysAuthSocialBindReqVO { | ||
| 21 | + | ||
| 22 | + @ApiModelProperty(value = "社交平台的类型", required = true, example = "10", notes = "参见 SysUserSocialTypeEnum 枚举值") | ||
| 23 | + @InEnum(SysSocialTypeEnum.class) | ||
| 24 | + @NotNull(message = "社交平台的类型不能为空") | ||
| 25 | + private Integer type; | ||
| 26 | + | ||
| 27 | + @ApiModelProperty(value = "授权码", required = true, example = "1024") | ||
| 28 | + @NotEmpty(message = "授权码不能为空") | ||
| 29 | + private String code; | ||
| 30 | + | ||
| 31 | + @ApiModelProperty(value = "state", required = true, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62") | ||
| 32 | + @NotEmpty(message = "state 不能为空") | ||
| 33 | + private String state; | ||
| 34 | + | ||
| 35 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/vo/auth/SysAuthSocialLogin2ReqVO.java
| @@ -14,7 +14,7 @@ import javax.validation.constraints.NotEmpty; | @@ -14,7 +14,7 @@ import javax.validation.constraints.NotEmpty; | ||
| 14 | import javax.validation.constraints.NotNull; | 14 | import javax.validation.constraints.NotNull; |
| 15 | import javax.validation.constraints.Pattern; | 15 | import javax.validation.constraints.Pattern; |
| 16 | 16 | ||
| 17 | -@ApiModel("社交登陆 Request VO,使用 code 授权码 + 账号密码") | 17 | +@ApiModel("社交登录 Request VO,使用 code 授权码 + 账号密码") |
| 18 | @Data | 18 | @Data |
| 19 | @NoArgsConstructor | 19 | @NoArgsConstructor |
| 20 | @AllArgsConstructor | 20 | @AllArgsConstructor |
| @@ -35,7 +35,7 @@ public class SysAuthSocialLogin2ReqVO { | @@ -35,7 +35,7 @@ public class SysAuthSocialLogin2ReqVO { | ||
| 35 | private String state; | 35 | private String state; |
| 36 | 36 | ||
| 37 | @ApiModelProperty(value = "账号", required = true, example = "yudaoyuanma") | 37 | @ApiModelProperty(value = "账号", required = true, example = "yudaoyuanma") |
| 38 | - @NotEmpty(message = "登陆账号不能为空") | 38 | + @NotEmpty(message = "登录账号不能为空") |
| 39 | @Length(min = 4, max = 16, message = "账号长度为 4-16 位") | 39 | @Length(min = 4, max = 16, message = "账号长度为 4-16 位") |
| 40 | @Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母") | 40 | @Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母") |
| 41 | private String username; | 41 | private String username; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/vo/auth/SysAuthSocialLoginReqVO.java
| @@ -12,7 +12,7 @@ import lombok.NoArgsConstructor; | @@ -12,7 +12,7 @@ import lombok.NoArgsConstructor; | ||
| 12 | import javax.validation.constraints.NotEmpty; | 12 | import javax.validation.constraints.NotEmpty; |
| 13 | import javax.validation.constraints.NotNull; | 13 | import javax.validation.constraints.NotNull; |
| 14 | 14 | ||
| 15 | -@ApiModel("社交登陆 Request VO,使用 code 授权码") | 15 | +@ApiModel("社交登录 Request VO,使用 code 授权码") |
| 16 | @Data | 16 | @Data |
| 17 | @NoArgsConstructor | 17 | @NoArgsConstructor |
| 18 | @AllArgsConstructor | 18 | @AllArgsConstructor |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/vo/auth/SysAuthSocialUnbindReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.adminserver.modules.system.enums.user.SysSocialTypeEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 5 | +import io.swagger.annotations.ApiModel; | ||
| 6 | +import io.swagger.annotations.ApiModelProperty; | ||
| 7 | +import lombok.AllArgsConstructor; | ||
| 8 | +import lombok.Builder; | ||
| 9 | +import lombok.Data; | ||
| 10 | +import lombok.NoArgsConstructor; | ||
| 11 | + | ||
| 12 | +import javax.validation.constraints.NotEmpty; | ||
| 13 | +import javax.validation.constraints.NotNull; | ||
| 14 | + | ||
| 15 | +@ApiModel("取消社交绑定 Request VO,使用 code 授权码") | ||
| 16 | +@Data | ||
| 17 | +@NoArgsConstructor | ||
| 18 | +@AllArgsConstructor | ||
| 19 | +@Builder | ||
| 20 | +public class SysAuthSocialUnbindReqVO { | ||
| 21 | + | ||
| 22 | + @ApiModelProperty(value = "社交平台的类型", required = true, example = "10", notes = "参见 SysUserSocialTypeEnum 枚举值") | ||
| 23 | + @InEnum(SysSocialTypeEnum.class) | ||
| 24 | + @NotNull(message = "社交平台的类型不能为空") | ||
| 25 | + private Integer type; | ||
| 26 | + | ||
| 27 | + @ApiModelProperty(value = "社交的全局编号", required = true, example = "IPRmJ0wvBptiPIlGEZiPewGwiEiE") | ||
| 28 | + @NotEmpty(message = "社交的全局编号不能为空") | ||
| 29 | + private String unionId; | ||
| 30 | + | ||
| 31 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/vo/session/SysUserSessionPageItemRespVO.java
| @@ -26,7 +26,7 @@ public class SysUserSessionPageItemRespVO extends PageParam { | @@ -26,7 +26,7 @@ public class SysUserSessionPageItemRespVO extends PageParam { | ||
| 26 | @ApiModelProperty(value = "浏览器 UserAgent", required = true, example = "Mozilla/5.0") | 26 | @ApiModelProperty(value = "浏览器 UserAgent", required = true, example = "Mozilla/5.0") |
| 27 | private String userAgent; | 27 | private String userAgent; |
| 28 | 28 | ||
| 29 | - @ApiModelProperty(value = "登陆时间", required = true) | 29 | + @ApiModelProperty(value = "登录时间", required = true) |
| 30 | private Date createTime; | 30 | private Date createTime; |
| 31 | 31 | ||
| 32 | @ApiModelProperty(value = "用户账号", required = true, example = "yudao") | 32 | @ApiModelProperty(value = "用户账号", required = true, example = "yudao") |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/logger/SysLoginLogController.java
| @@ -27,7 +27,7 @@ import java.util.List; | @@ -27,7 +27,7 @@ import java.util.List; | ||
| 27 | 27 | ||
| 28 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | 28 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 29 | 29 | ||
| 30 | -@Api(tags = "登陆日志") | 30 | +@Api(tags = "登录日志") |
| 31 | @RestController | 31 | @RestController |
| 32 | @RequestMapping("/system/login-log") | 32 | @RequestMapping("/system/login-log") |
| 33 | @Validated | 33 | @Validated |
| @@ -37,7 +37,7 @@ public class SysLoginLogController { | @@ -37,7 +37,7 @@ public class SysLoginLogController { | ||
| 37 | private SysLoginLogService loginLogService; | 37 | private SysLoginLogService loginLogService; |
| 38 | 38 | ||
| 39 | @GetMapping("/page") | 39 | @GetMapping("/page") |
| 40 | - @ApiOperation("获得登陆日志分页列表") | 40 | + @ApiOperation("获得登录日志分页列表") |
| 41 | @PreAuthorize("@ss.hasPermission('system:login-log:query')") | 41 | @PreAuthorize("@ss.hasPermission('system:login-log:query')") |
| 42 | public CommonResult<PageResult<SysLoginLogRespVO>> getLoginLogPage(@Valid SysLoginLogPageReqVO reqVO) { | 42 | public CommonResult<PageResult<SysLoginLogRespVO>> getLoginLogPage(@Valid SysLoginLogPageReqVO reqVO) { |
| 43 | PageResult<SysLoginLogDO> page = loginLogService.getLoginLogPage(reqVO); | 43 | PageResult<SysLoginLogDO> page = loginLogService.getLoginLogPage(reqVO); |
| @@ -45,7 +45,7 @@ public class SysLoginLogController { | @@ -45,7 +45,7 @@ public class SysLoginLogController { | ||
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | @GetMapping("/export") | 47 | @GetMapping("/export") |
| 48 | - @ApiOperation("导出登陆日志 Excel") | 48 | + @ApiOperation("导出登录日志 Excel") |
| 49 | @PreAuthorize("@ss.hasPermission('system:login-log:export')") | 49 | @PreAuthorize("@ss.hasPermission('system:login-log:export')") |
| 50 | @OperateLog(type = EXPORT) | 50 | @OperateLog(type = EXPORT) |
| 51 | public void exportLoginLog(HttpServletResponse response, @Valid SysLoginLogExportReqVO reqVO) throws IOException { | 51 | public void exportLoginLog(HttpServletResponse response, @Valid SysLoginLogExportReqVO reqVO) throws IOException { |
| @@ -53,7 +53,7 @@ public class SysLoginLogController { | @@ -53,7 +53,7 @@ public class SysLoginLogController { | ||
| 53 | // 拼接数据 | 53 | // 拼接数据 |
| 54 | List<SysLoginLogExcelVO> data = SysLoginLogConvert.INSTANCE.convertList(list); | 54 | List<SysLoginLogExcelVO> data = SysLoginLogConvert.INSTANCE.convertList(list); |
| 55 | // 输出 | 55 | // 输出 |
| 56 | - ExcelUtils.write(response, "登陆日志.xls", "数据列表", SysLoginLogExcelVO.class, data); | 56 | + ExcelUtils.write(response, "登录日志.xls", "数据列表", SysLoginLogExcelVO.class, data); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | } | 59 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/logger/vo/loginlog/SysLoginLogBaseVO.java
| @@ -9,7 +9,7 @@ import javax.validation.constraints.NotNull; | @@ -9,7 +9,7 @@ import javax.validation.constraints.NotNull; | ||
| 9 | import javax.validation.constraints.Size; | 9 | import javax.validation.constraints.Size; |
| 10 | 10 | ||
| 11 | /** | 11 | /** |
| 12 | - * 登陆日志 Base VO,提供给添加、修改、详细的子 VO 使用 | 12 | + * 登录日志 Base VO,提供给添加、修改、详细的子 VO 使用 |
| 13 | * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | 13 | * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 |
| 14 | */ | 14 | */ |
| 15 | @Data | 15 | @Data |
| @@ -28,8 +28,8 @@ public class SysLoginLogBaseVO { | @@ -28,8 +28,8 @@ public class SysLoginLogBaseVO { | ||
| 28 | @Size(max = 30, message = "用户账号长度不能超过30个字符") | 28 | @Size(max = 30, message = "用户账号长度不能超过30个字符") |
| 29 | private String username; | 29 | private String username; |
| 30 | 30 | ||
| 31 | - @ApiModelProperty(value = "登陆结果", required = true, example = "1", notes = "参见 SysLoginResultEnum 枚举类") | ||
| 32 | - @NotNull(message = "登陆结果不能为空") | 31 | + @ApiModelProperty(value = "登录结果", required = true, example = "1", notes = "参见 SysLoginResultEnum 枚举类") |
| 32 | + @NotNull(message = "登录结果不能为空") | ||
| 33 | private Integer result; | 33 | private Integer result; |
| 34 | 34 | ||
| 35 | @ApiModelProperty(value = "用户 IP", required = true, example = "127.0.0.1") | 35 | @ApiModelProperty(value = "用户 IP", required = true, example = "127.0.0.1") |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/logger/vo/loginlog/SysLoginLogCreateReqVO.java
| @@ -5,8 +5,8 @@ import lombok.Data; | @@ -5,8 +5,8 @@ import lombok.Data; | ||
| 5 | import lombok.EqualsAndHashCode; | 5 | import lombok.EqualsAndHashCode; |
| 6 | import lombok.ToString; | 6 | import lombok.ToString; |
| 7 | 7 | ||
| 8 | -@ApiModel(value = "登陆日志创建 Request VO", | ||
| 9 | - description = "暂时提供给前端,仅仅后端记录登陆日志时,进行使用") | 8 | +@ApiModel(value = "登录日志创建 Request VO", |
| 9 | + description = "暂时提供给前端,仅仅后端记录登录日志时,进行使用") | ||
| 10 | @Data | 10 | @Data |
| 11 | @EqualsAndHashCode(callSuper = true) | 11 | @EqualsAndHashCode(callSuper = true) |
| 12 | @ToString(callSuper = true) | 12 | @ToString(callSuper = true) |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/logger/vo/loginlog/SysLoginLogExcelVO.java
| @@ -9,7 +9,7 @@ import lombok.Data; | @@ -9,7 +9,7 @@ import lombok.Data; | ||
| 9 | import java.util.Date; | 9 | import java.util.Date; |
| 10 | 10 | ||
| 11 | /** | 11 | /** |
| 12 | - * 登陆日志 Excel 导出响应 VO | 12 | + * 登录日志 Excel 导出响应 VO |
| 13 | */ | 13 | */ |
| 14 | @Data | 14 | @Data |
| 15 | public class SysLoginLogExcelVO { | 15 | public class SysLoginLogExcelVO { |
| @@ -24,17 +24,17 @@ public class SysLoginLogExcelVO { | @@ -24,17 +24,17 @@ public class SysLoginLogExcelVO { | ||
| 24 | @DictFormat(SysDictTypeConstants.LOGIN_TYPE) | 24 | @DictFormat(SysDictTypeConstants.LOGIN_TYPE) |
| 25 | private Integer logType; | 25 | private Integer logType; |
| 26 | 26 | ||
| 27 | - @ExcelProperty(value = "登陆结果", converter = DictConvert.class) | 27 | + @ExcelProperty(value = "登录结果", converter = DictConvert.class) |
| 28 | @DictFormat(SysDictTypeConstants.LOGIN_RESULT) | 28 | @DictFormat(SysDictTypeConstants.LOGIN_RESULT) |
| 29 | private Integer result; | 29 | private Integer result; |
| 30 | 30 | ||
| 31 | - @ExcelProperty("登陆 IP") | 31 | + @ExcelProperty("登录 IP") |
| 32 | private String userIp; | 32 | private String userIp; |
| 33 | 33 | ||
| 34 | @ExcelProperty("浏览器 UA") | 34 | @ExcelProperty("浏览器 UA") |
| 35 | private String userAgent; | 35 | private String userAgent; |
| 36 | 36 | ||
| 37 | - @ExcelProperty("登陆时间") | 37 | + @ExcelProperty("登录时间") |
| 38 | private Date createTime; | 38 | private Date createTime; |
| 39 | 39 | ||
| 40 | } | 40 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/logger/vo/loginlog/SysLoginLogExportReqVO.java
| @@ -9,7 +9,7 @@ import java.util.Date; | @@ -9,7 +9,7 @@ import java.util.Date; | ||
| 9 | 9 | ||
| 10 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | 10 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 11 | 11 | ||
| 12 | -@ApiModel("登陆日志分页列表 Request VO") | 12 | +@ApiModel("登录日志分页列表 Request VO") |
| 13 | @Data | 13 | @Data |
| 14 | public class SysLoginLogExportReqVO { | 14 | public class SysLoginLogExportReqVO { |
| 15 | 15 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/logger/vo/loginlog/SysLoginLogPageReqVO.java
| @@ -11,7 +11,7 @@ import java.util.Date; | @@ -11,7 +11,7 @@ import java.util.Date; | ||
| 11 | 11 | ||
| 12 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | 12 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 13 | 13 | ||
| 14 | -@ApiModel("登陆日志分页列表 Request VO") | 14 | +@ApiModel("登录日志分页列表 Request VO") |
| 15 | @Data | 15 | @Data |
| 16 | @EqualsAndHashCode(callSuper = true) | 16 | @EqualsAndHashCode(callSuper = true) |
| 17 | public class SysLoginLogPageReqVO extends PageParam { | 17 | public class SysLoginLogPageReqVO extends PageParam { |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/logger/vo/loginlog/SysLoginLogRespVO.java
| @@ -9,7 +9,7 @@ import lombok.ToString; | @@ -9,7 +9,7 @@ import lombok.ToString; | ||
| 9 | import javax.validation.constraints.NotNull; | 9 | import javax.validation.constraints.NotNull; |
| 10 | import java.util.Date; | 10 | import java.util.Date; |
| 11 | 11 | ||
| 12 | -@ApiModel("登陆日志 Response VO") | 12 | +@ApiModel("登录日志 Response VO") |
| 13 | @Data | 13 | @Data |
| 14 | @EqualsAndHashCode(callSuper = true) | 14 | @EqualsAndHashCode(callSuper = true) |
| 15 | @ToString(callSuper = true) | 15 | @ToString(callSuper = true) |
| @@ -26,7 +26,7 @@ public class SysLoginLogRespVO extends SysLoginLogBaseVO { | @@ -26,7 +26,7 @@ public class SysLoginLogRespVO extends SysLoginLogBaseVO { | ||
| 26 | @NotNull(message = "用户类型不能为空") | 26 | @NotNull(message = "用户类型不能为空") |
| 27 | private Integer userType; | 27 | private Integer userType; |
| 28 | 28 | ||
| 29 | - @ApiModelProperty(value = "登陆时间", required = true) | 29 | + @ApiModelProperty(value = "登录时间", required = true) |
| 30 | private Date createTime; | 30 | private Date createTime; |
| 31 | 31 | ||
| 32 | } | 32 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/user/SysUserProfileController.http
0 → 100644
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/user/SysUserProfileController.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.controller.user; | 1 | package cn.iocoder.yudao.adminserver.modules.system.controller.user; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.social.SysSocialUserDO; | ||
| 5 | +import cn.iocoder.yudao.adminserver.modules.system.service.social.SysSocialService; | ||
| 4 | import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; | 6 | import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 7 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileRespVO; | 8 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileRespVO; |
| @@ -52,6 +54,8 @@ public class SysUserProfileController { | @@ -52,6 +54,8 @@ public class SysUserProfileController { | ||
| 52 | private SysPermissionService permissionService; | 54 | private SysPermissionService permissionService; |
| 53 | @Resource | 55 | @Resource |
| 54 | private SysRoleService roleService; | 56 | private SysRoleService roleService; |
| 57 | + @Resource | ||
| 58 | + private SysSocialService socialService; | ||
| 55 | 59 | ||
| 56 | @GetMapping("/get") | 60 | @GetMapping("/get") |
| 57 | @ApiOperation("获得登录用户信息") | 61 | @ApiOperation("获得登录用户信息") |
| @@ -72,6 +76,9 @@ public class SysUserProfileController { | @@ -72,6 +76,9 @@ public class SysUserProfileController { | ||
| 72 | List<SysPostDO> posts = postService.getPosts(user.getPostIds()); | 76 | List<SysPostDO> posts = postService.getPosts(user.getPostIds()); |
| 73 | resp.setPosts(SysUserConvert.INSTANCE.convertList02(posts)); | 77 | resp.setPosts(SysUserConvert.INSTANCE.convertList02(posts)); |
| 74 | } | 78 | } |
| 79 | + // 获得社交用户信息 | ||
| 80 | + List<SysSocialUserDO> socialUsers = socialService.getSocialUserList(user.getId()); | ||
| 81 | + resp.setSocialUsers(SysUserConvert.INSTANCE.convertList03(socialUsers)); | ||
| 75 | return success(resp); | 82 | return success(resp); |
| 76 | } | 83 | } |
| 77 | 84 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/user/vo/profile/SysUserProfileRespVO.java
| @@ -25,7 +25,7 @@ public class SysUserProfileRespVO extends SysUserBaseVO { | @@ -25,7 +25,7 @@ public class SysUserProfileRespVO extends SysUserBaseVO { | ||
| 25 | @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类") | 25 | @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类") |
| 26 | private Integer status; | 26 | private Integer status; |
| 27 | 27 | ||
| 28 | - @ApiModelProperty(value = "最后登陆 IP", required = true, example = "192.168.1.1") | 28 | + @ApiModelProperty(value = "最后登录 IP", required = true, example = "192.168.1.1") |
| 29 | private String loginIp; | 29 | private String loginIp; |
| 30 | 30 | ||
| 31 | @ApiModelProperty(value = "最后登录时间", required = true, example = "时间戳格式") | 31 | @ApiModelProperty(value = "最后登录时间", required = true, example = "时间戳格式") |
| @@ -48,6 +48,10 @@ public class SysUserProfileRespVO extends SysUserBaseVO { | @@ -48,6 +48,10 @@ public class SysUserProfileRespVO extends SysUserBaseVO { | ||
| 48 | * 所属岗位数组 | 48 | * 所属岗位数组 |
| 49 | */ | 49 | */ |
| 50 | private List<Post> posts; | 50 | private List<Post> posts; |
| 51 | + /** | ||
| 52 | + * 社交用户数组 | ||
| 53 | + */ | ||
| 54 | + private List<SocialUser> socialUsers; | ||
| 51 | 55 | ||
| 52 | @ApiModel("角色") | 56 | @ApiModel("角色") |
| 53 | @Data | 57 | @Data |
| @@ -85,4 +89,16 @@ public class SysUserProfileRespVO extends SysUserBaseVO { | @@ -85,4 +89,16 @@ public class SysUserProfileRespVO extends SysUserBaseVO { | ||
| 85 | 89 | ||
| 86 | } | 90 | } |
| 87 | 91 | ||
| 92 | + @ApiModel("社交用户") | ||
| 93 | + @Data | ||
| 94 | + public static class SocialUser { | ||
| 95 | + | ||
| 96 | + @ApiModelProperty(value = "社交平台的类型", required = true, example = "10", notes = "参见 SysSocialTypeEnum 枚举类") | ||
| 97 | + private Integer type; | ||
| 98 | + | ||
| 99 | + @ApiModelProperty(value = "社交的全局编号", required = true, example = "IPRmJ0wvBptiPIlGEZiPewGwiEiE") | ||
| 100 | + private String unionId; | ||
| 101 | + | ||
| 102 | + } | ||
| 103 | + | ||
| 88 | } | 104 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/user/vo/user/SysUserRespVO.java
| @@ -19,7 +19,7 @@ public class SysUserRespVO extends SysUserBaseVO { | @@ -19,7 +19,7 @@ public class SysUserRespVO extends SysUserBaseVO { | ||
| 19 | @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类") | 19 | @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类") |
| 20 | private Integer status; | 20 | private Integer status; |
| 21 | 21 | ||
| 22 | - @ApiModelProperty(value = "最后登陆 IP", required = true, example = "192.168.1.1") | 22 | + @ApiModelProperty(value = "最后登录 IP", required = true, example = "192.168.1.1") |
| 23 | private String loginIp; | 23 | private String loginIp; |
| 24 | 24 | ||
| 25 | @ApiModelProperty(value = "最后登录时间", required = true, example = "时间戳格式") | 25 | @ApiModelProperty(value = "最后登录时间", required = true, example = "时间戳格式") |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/convert/user/SysUserConvert.java
| @@ -7,6 +7,7 @@ import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.*; | @@ -7,6 +7,7 @@ import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.*; | ||
| 7 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; | 7 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; |
| 8 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysPostDO; | 8 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysPostDO; |
| 9 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysRoleDO; | 9 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysRoleDO; |
| 10 | +import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.social.SysSocialUserDO; | ||
| 10 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | 11 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; |
| 11 | import org.mapstruct.Mapper; | 12 | import org.mapstruct.Mapper; |
| 12 | import org.mapstruct.factory.Mappers; | 13 | import org.mapstruct.factory.Mappers; |
| @@ -42,4 +43,6 @@ public interface SysUserConvert { | @@ -42,4 +43,6 @@ public interface SysUserConvert { | ||
| 42 | 43 | ||
| 43 | List<SysUserProfileRespVO.Post> convertList02(List<SysPostDO> list); | 44 | List<SysUserProfileRespVO.Post> convertList02(List<SysPostDO> list); |
| 44 | 45 | ||
| 46 | + List<SysUserProfileRespVO.SocialUser> convertList03(List<SysSocialUserDO> list); | ||
| 47 | + | ||
| 45 | } | 48 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/dataobject/logger/SysLoginLogDO.java
| @@ -10,9 +10,9 @@ import lombok.EqualsAndHashCode; | @@ -10,9 +10,9 @@ import lombok.EqualsAndHashCode; | ||
| 10 | import lombok.ToString; | 10 | import lombok.ToString; |
| 11 | 11 | ||
| 12 | /** | 12 | /** |
| 13 | - * 登陆日志表 | 13 | + * 登录日志表 |
| 14 | * | 14 | * |
| 15 | - * 注意,包括登陆和登出两种行为 | 15 | + * 注意,包括登录和登出两种行为 |
| 16 | * | 16 | * |
| 17 | * @author ruoyi | 17 | * @author ruoyi |
| 18 | */ | 18 | */ |
| @@ -53,7 +53,7 @@ public class SysLoginLogDO extends BaseDO { | @@ -53,7 +53,7 @@ public class SysLoginLogDO extends BaseDO { | ||
| 53 | */ | 53 | */ |
| 54 | private String username; | 54 | private String username; |
| 55 | /** | 55 | /** |
| 56 | - * 登陆结果 | 56 | + * 登录结果 |
| 57 | * | 57 | * |
| 58 | * 枚举 {@link SysLoginResultEnum} | 58 | * 枚举 {@link SysLoginResultEnum} |
| 59 | */ | 59 | */ |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/mysql/social/SysSocialUserMapper.java
| @@ -21,4 +21,8 @@ public interface SysSocialUserMapper extends BaseMapperX<SysSocialUserDO> { | @@ -21,4 +21,8 @@ public interface SysSocialUserMapper extends BaseMapperX<SysSocialUserDO> { | ||
| 21 | .in("type", types).eq("user_id", userId)); | 21 | .in("type", types).eq("user_id", userId)); |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | + default List<SysSocialUserDO> selectListByUserId(Integer userType, Long userId) { | ||
| 25 | + return selectList(new QueryWrapper<SysSocialUserDO>().eq("user_type", userType).eq("user_id", userId)); | ||
| 26 | + } | ||
| 27 | + | ||
| 24 | } | 28 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/redis/SysRedisKeyConstants.java
| @@ -15,7 +15,7 @@ import static cn.iocoder.yudao.framework.redis.core.RedisKeyDefine.KeyTypeEnum.S | @@ -15,7 +15,7 @@ import static cn.iocoder.yudao.framework.redis.core.RedisKeyDefine.KeyTypeEnum.S | ||
| 15 | */ | 15 | */ |
| 16 | public interface SysRedisKeyConstants { | 16 | public interface SysRedisKeyConstants { |
| 17 | 17 | ||
| 18 | - RedisKeyDefine LOGIN_USER = new RedisKeyDefine("登陆用户的缓存", | 18 | + RedisKeyDefine LOGIN_USER = new RedisKeyDefine("登录用户的缓存", |
| 19 | "login_user:%s", // 参数为 sessionId | 19 | "login_user:%s", // 参数为 sessionId |
| 20 | STRING, LoginUser.class, RedisKeyDefine.TimeoutTypeEnum.DYNAMIC); | 20 | STRING, LoginUser.class, RedisKeyDefine.TimeoutTypeEnum.DYNAMIC); |
| 21 | 21 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/SysDictTypeConstants.java
| @@ -12,8 +12,8 @@ public interface SysDictTypeConstants { | @@ -12,8 +12,8 @@ public interface SysDictTypeConstants { | ||
| 12 | 12 | ||
| 13 | String USER_SEX = "sys_user_sex"; // 用户性别 | 13 | String USER_SEX = "sys_user_sex"; // 用户性别 |
| 14 | String OPERATE_TYPE = "sys_operate_type"; // 操作类型 | 14 | String OPERATE_TYPE = "sys_operate_type"; // 操作类型 |
| 15 | - String LOGIN_TYPE = "sys_login_type"; // 登陆日志的类型 | ||
| 16 | - String LOGIN_RESULT = "sys_login_result"; // 登陆结果 | 15 | + String LOGIN_TYPE = "sys_login_type"; // 登录日志的类型 |
| 16 | + String LOGIN_RESULT = "sys_login_result"; // 登录结果 | ||
| 17 | String CONFIG_TYPE = "sys_config_type"; // 参数配置类型 | 17 | String CONFIG_TYPE = "sys_config_type"; // 参数配置类型 |
| 18 | String BOOLEAN_STRING = "sys_boolean_string"; // Boolean 是否类型 | 18 | String BOOLEAN_STRING = "sys_boolean_string"; // Boolean 是否类型 |
| 19 | 19 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/SysErrorCodeConstants.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.adminserver.modules.system.enums; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.adminserver.modules.system.enums; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.adminserver.modules.tool.framework.errorcode.config.ErrorCodeConfiguration; | 3 | import cn.iocoder.yudao.adminserver.modules.tool.framework.errorcode.config.ErrorCodeConfiguration; |
| 4 | import cn.iocoder.yudao.framework.common.exception.ErrorCode; | 4 | import cn.iocoder.yudao.framework.common.exception.ErrorCode; |
| 5 | +import org.springframework.validation.Errors; | ||
| 5 | 6 | ||
| 6 | /** | 7 | /** |
| 7 | * System 错误码枚举类 | 8 | * System 错误码枚举类 |
| @@ -13,7 +14,7 @@ public interface SysErrorCodeConstants { | @@ -13,7 +14,7 @@ public interface SysErrorCodeConstants { | ||
| 13 | // ========== AUTH 模块 1002000000 ========== | 14 | // ========== AUTH 模块 1002000000 ========== |
| 14 | ErrorCode AUTH_LOGIN_BAD_CREDENTIALS = new ErrorCode(1002000000, "登录失败,账号密码不正确"); | 15 | ErrorCode AUTH_LOGIN_BAD_CREDENTIALS = new ErrorCode(1002000000, "登录失败,账号密码不正确"); |
| 15 | ErrorCode AUTH_LOGIN_USER_DISABLED = new ErrorCode(1002000001, "登录失败,账号被禁用"); | 16 | ErrorCode AUTH_LOGIN_USER_DISABLED = new ErrorCode(1002000001, "登录失败,账号被禁用"); |
| 16 | - ErrorCode AUTH_LOGIN_FAIL_UNKNOWN = new ErrorCode(1002000002, "登录失败"); // 登陆失败的兜底,位置原因 | 17 | + ErrorCode AUTH_LOGIN_FAIL_UNKNOWN = new ErrorCode(1002000002, "登录失败"); // 登录失败的兜底,位置原因 |
| 17 | ErrorCode AUTH_LOGIN_CAPTCHA_NOT_FOUND = new ErrorCode(1002000003, "验证码不存在"); | 18 | ErrorCode AUTH_LOGIN_CAPTCHA_NOT_FOUND = new ErrorCode(1002000003, "验证码不存在"); |
| 18 | ErrorCode AUTH_LOGIN_CAPTCHA_CODE_ERROR = new ErrorCode(1002000004, "验证码不正确"); | 19 | ErrorCode AUTH_LOGIN_CAPTCHA_CODE_ERROR = new ErrorCode(1002000004, "验证码不正确"); |
| 19 | ErrorCode AUTH_THIRD_LOGIN_NOT_BIND = new ErrorCode(1002000005, "未绑定账号,需要进行绑定"); | 20 | ErrorCode AUTH_THIRD_LOGIN_NOT_BIND = new ErrorCode(1002000005, "未绑定账号,需要进行绑定"); |
| @@ -99,5 +100,6 @@ public interface SysErrorCodeConstants { | @@ -99,5 +100,6 @@ public interface SysErrorCodeConstants { | ||
| 99 | 100 | ||
| 100 | // ========== 社交模块 1002014000 ========== | 101 | // ========== 社交模块 1002014000 ========== |
| 101 | ErrorCode SOCIAL_AUTH_FAILURE = new ErrorCode(1002014000, "社交授权失败,原因是:{}"); | 102 | ErrorCode SOCIAL_AUTH_FAILURE = new ErrorCode(1002014000, "社交授权失败,原因是:{}"); |
| 103 | + ErrorCode SOCIAL_UNBIND_NOT_SELF = new ErrorCode(1002014001, "社交解绑失败,非当前用户绑定"); | ||
| 102 | 104 | ||
| 103 | } | 105 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/logger/SysLoginLogTypeEnum.java
| @@ -4,15 +4,15 @@ import lombok.AllArgsConstructor; | @@ -4,15 +4,15 @@ import lombok.AllArgsConstructor; | ||
| 4 | import lombok.Getter; | 4 | import lombok.Getter; |
| 5 | 5 | ||
| 6 | /** | 6 | /** |
| 7 | - * 登陆日志的类型枚举 | 7 | + * 登录日志的类型枚举 |
| 8 | */ | 8 | */ |
| 9 | @Getter | 9 | @Getter |
| 10 | @AllArgsConstructor | 10 | @AllArgsConstructor |
| 11 | public enum SysLoginLogTypeEnum { | 11 | public enum SysLoginLogTypeEnum { |
| 12 | 12 | ||
| 13 | LOGIN_USERNAME(100), // 使用账号登录 | 13 | LOGIN_USERNAME(100), // 使用账号登录 |
| 14 | - LOGIN_SOCIAL(101), // 使用社交登陆 | ||
| 15 | - LOGIN_MOCK(102), // 使用 Mock 登陆 | 14 | + LOGIN_SOCIAL(101), // 使用社交登录 |
| 15 | + LOGIN_MOCK(102), // 使用 Mock 登录 | ||
| 16 | 16 | ||
| 17 | LOGOUT_SELF(200), // 自己主动登出 | 17 | LOGOUT_SELF(200), // 自己主动登出 |
| 18 | LOGOUT_TIMEOUT(201), // 超时登出 | 18 | LOGOUT_TIMEOUT(201), // 超时登出 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/logger/SysLoginResultEnum.java
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/auth/SysAuthService.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.service.auth; | 1 | package cn.iocoder.yudao.adminserver.modules.system.service.auth; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthSocialLogin2ReqVO; | ||
| 4 | -import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthSocialLoginReqVO; | 3 | +import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.*; |
| 5 | import cn.iocoder.yudao.framework.security.core.service.SecurityAuthFrameworkService; | 4 | import cn.iocoder.yudao.framework.security.core.service.SecurityAuthFrameworkService; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthLoginReqVO; | 5 | + |
| 6 | +import javax.validation.Valid; | ||
| 7 | 7 | ||
| 8 | /** | 8 | /** |
| 9 | * 认证 Service 接口 | 9 | * 认证 Service 接口 |
| 10 | * | 10 | * |
| 11 | - * 提供用户的账号密码登陆、token 的校验等认证相关的功能 | 11 | + * 提供用户的账号密码登录、token 的校验等认证相关的功能 |
| 12 | * | 12 | * |
| 13 | * @author 芋道源码 | 13 | * @author 芋道源码 |
| 14 | */ | 14 | */ |
| 15 | public interface SysAuthService extends SecurityAuthFrameworkService { | 15 | public interface SysAuthService extends SecurityAuthFrameworkService { |
| 16 | 16 | ||
| 17 | /** | 17 | /** |
| 18 | - * 登陆用户 | 18 | + * 账号登录 |
| 19 | * | 19 | * |
| 20 | - * @param reqVO 登陆信息 | 20 | + * @param reqVO 登录信息 |
| 21 | * @param userIp 用户 IP | 21 | * @param userIp 用户 IP |
| 22 | * @param userAgent 用户 UA | 22 | * @param userAgent 用户 UA |
| 23 | * @return 身份令牌,使用 JWT 方式 | 23 | * @return 身份令牌,使用 JWT 方式 |
| 24 | */ | 24 | */ |
| 25 | - String login(SysAuthLoginReqVO reqVO, String userIp, String userAgent); | 25 | + String login(@Valid SysAuthLoginReqVO reqVO, String userIp, String userAgent); |
| 26 | 26 | ||
| 27 | /** | 27 | /** |
| 28 | - * 社交登陆用户,使用 code 授权码 | 28 | + * 社交登录,使用 code 授权码 |
| 29 | * | 29 | * |
| 30 | - * @param reqVO 登陆信息 | 30 | + * @param reqVO 登录信息 |
| 31 | * @param userIp 用户 IP | 31 | * @param userIp 用户 IP |
| 32 | * @param userAgent 用户 UA | 32 | * @param userAgent 用户 UA |
| 33 | * @return 身份令牌,使用 JWT 方式 | 33 | * @return 身份令牌,使用 JWT 方式 |
| 34 | */ | 34 | */ |
| 35 | - String socialLogin(SysAuthSocialLoginReqVO reqVO, String userIp, String userAgent); | 35 | + String socialLogin(@Valid SysAuthSocialLoginReqVO reqVO, String userIp, String userAgent); |
| 36 | 36 | ||
| 37 | /** | 37 | /** |
| 38 | - * 社交登陆用户,使用 code 授权码 + 账号密码 | 38 | + * 社交登录,使用 code 授权码 + 账号密码 |
| 39 | * | 39 | * |
| 40 | - * @param reqVO 登陆信息 | 40 | + * @param reqVO 登录信息 |
| 41 | * @param userIp 用户 IP | 41 | * @param userIp 用户 IP |
| 42 | * @param userAgent 用户 UA | 42 | * @param userAgent 用户 UA |
| 43 | * @return 身份令牌,使用 JWT 方式 | 43 | * @return 身份令牌,使用 JWT 方式 |
| 44 | */ | 44 | */ |
| 45 | - String socialLogin2(SysAuthSocialLogin2ReqVO reqVO, String userIp, String userAgent); | 45 | + String socialLogin2(@Valid SysAuthSocialLogin2ReqVO reqVO, String userIp, String userAgent); |
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 社交绑定,使用 code 授权码 | ||
| 49 | + * | ||
| 50 | + * @param userId 用户编号 | ||
| 51 | + * @param reqVO 绑定信息 | ||
| 52 | + */ | ||
| 53 | + void socialBind(Long userId, @Valid SysAuthSocialBindReqVO reqVO); | ||
| 46 | 54 | ||
| 47 | } | 55 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/auth/SysUserSessionService.java
| @@ -15,7 +15,7 @@ public interface SysUserSessionService { | @@ -15,7 +15,7 @@ public interface SysUserSessionService { | ||
| 15 | /** | 15 | /** |
| 16 | * 创建在线用户 Session | 16 | * 创建在线用户 Session |
| 17 | * | 17 | * |
| 18 | - * @param loginUser 登陆用户 | 18 | + * @param loginUser 登录用户 |
| 19 | * @param userIp 用户 IP | 19 | * @param userIp 用户 IP |
| 20 | * @param userAgent 用户 UA | 20 | * @param userAgent 用户 UA |
| 21 | * @return Session 编号 | 21 | * @return Session 编号 |
| @@ -26,7 +26,7 @@ public interface SysUserSessionService { | @@ -26,7 +26,7 @@ public interface SysUserSessionService { | ||
| 26 | * 刷新在线用户 Session 的更新时间 | 26 | * 刷新在线用户 Session 的更新时间 |
| 27 | * | 27 | * |
| 28 | * @param sessionId Session 编号 | 28 | * @param sessionId Session 编号 |
| 29 | - * @param loginUser 登陆用户 | 29 | + * @param loginUser 登录用户 |
| 30 | */ | 30 | */ |
| 31 | void refreshUserSession(String sessionId, LoginUser loginUser); | 31 | void refreshUserSession(String sessionId, LoginUser loginUser); |
| 32 | 32 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/auth/impl/SysAuthServiceImpl.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.adminserver.modules.system.service.auth.impl; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.adminserver.modules.system.service.auth.impl; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthLoginReqVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthLoginReqVO; |
| 5 | +import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthSocialBindReqVO; | ||
| 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthSocialLogin2ReqVO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthSocialLogin2ReqVO; |
| 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthSocialLoginReqVO; | 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthSocialLoginReqVO; |
| 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.loginlog.SysLoginLogCreateReqVO; | 8 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.loginlog.SysLoginLogCreateReqVO; |
| @@ -18,7 +19,6 @@ import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermiss | @@ -18,7 +19,6 @@ import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermiss | ||
| 18 | import cn.iocoder.yudao.adminserver.modules.system.service.social.SysSocialService; | 19 | import cn.iocoder.yudao.adminserver.modules.system.service.social.SysSocialService; |
| 19 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; | 20 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; |
| 20 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 21 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 21 | -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; | ||
| 22 | import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; | 22 | import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; |
| 23 | import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; | 23 | import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; |
| 24 | import cn.iocoder.yudao.framework.security.core.LoginUser; | 24 | import cn.iocoder.yudao.framework.security.core.LoginUser; |
| @@ -101,11 +101,11 @@ public class SysAuthServiceImpl implements SysAuthService { | @@ -101,11 +101,11 @@ public class SysAuthServiceImpl implements SysAuthService { | ||
| 101 | // 判断验证码是否正确 | 101 | // 判断验证码是否正确 |
| 102 | this.verifyCaptcha(reqVO.getUsername(), reqVO.getUuid(), reqVO.getCode()); | 102 | this.verifyCaptcha(reqVO.getUsername(), reqVO.getUuid(), reqVO.getCode()); |
| 103 | 103 | ||
| 104 | - // 使用账号密码,进行登陆。 | 104 | + // 使用账号密码,进行登录。 |
| 105 | LoginUser loginUser = this.login0(reqVO.getUsername(), reqVO.getPassword()); | 105 | LoginUser loginUser = this.login0(reqVO.getUsername(), reqVO.getPassword()); |
| 106 | loginUser.setRoleIds(this.getUserRoleIds(loginUser.getId())); // 获取用户角色列表 | 106 | loginUser.setRoleIds(this.getUserRoleIds(loginUser.getId())); // 获取用户角色列表 |
| 107 | 107 | ||
| 108 | - // 缓存登陆用户到 Redis 中,返回 sessionId 编号 | 108 | + // 缓存登录用户到 Redis 中,返回 sessionId 编号 |
| 109 | return userSessionService.createUserSession(loginUser, userIp, userAgent); | 109 | return userSessionService.createUserSession(loginUser, userIp, userAgent); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| @@ -114,13 +114,13 @@ public class SysAuthServiceImpl implements SysAuthService { | @@ -114,13 +114,13 @@ public class SysAuthServiceImpl implements SysAuthService { | ||
| 114 | String code = captchaService.getCaptchaCode(captchaUUID); | 114 | String code = captchaService.getCaptchaCode(captchaUUID); |
| 115 | // 验证码不存在 | 115 | // 验证码不存在 |
| 116 | if (code == null) { | 116 | if (code == null) { |
| 117 | - // 创建登陆失败日志(验证码不存在) | 117 | + // 创建登录失败日志(验证码不存在) |
| 118 | this.createLoginLog(username, logTypeEnum, SysLoginResultEnum.CAPTCHA_NOT_FOUND); | 118 | this.createLoginLog(username, logTypeEnum, SysLoginResultEnum.CAPTCHA_NOT_FOUND); |
| 119 | throw exception(AUTH_LOGIN_CAPTCHA_NOT_FOUND); | 119 | throw exception(AUTH_LOGIN_CAPTCHA_NOT_FOUND); |
| 120 | } | 120 | } |
| 121 | // 验证码不正确 | 121 | // 验证码不正确 |
| 122 | if (!code.equals(captchaCode)) { | 122 | if (!code.equals(captchaCode)) { |
| 123 | - // 创建登陆失败日志(验证码不正确) | 123 | + // 创建登录失败日志(验证码不正确) |
| 124 | this.createLoginLog(username, logTypeEnum, SysLoginResultEnum.CAPTCHA_CODE_ERROR); | 124 | this.createLoginLog(username, logTypeEnum, SysLoginResultEnum.CAPTCHA_CODE_ERROR); |
| 125 | throw exception(AUTH_LOGIN_CAPTCHA_CODE_ERROR); | 125 | throw exception(AUTH_LOGIN_CAPTCHA_CODE_ERROR); |
| 126 | } | 126 | } |
| @@ -147,7 +147,7 @@ public class SysAuthServiceImpl implements SysAuthService { | @@ -147,7 +147,7 @@ public class SysAuthServiceImpl implements SysAuthService { | ||
| 147 | this.createLoginLog(username, logTypeEnum, SysLoginResultEnum.UNKNOWN_ERROR); | 147 | this.createLoginLog(username, logTypeEnum, SysLoginResultEnum.UNKNOWN_ERROR); |
| 148 | throw exception(AUTH_LOGIN_FAIL_UNKNOWN); | 148 | throw exception(AUTH_LOGIN_FAIL_UNKNOWN); |
| 149 | } | 149 | } |
| 150 | - // 登陆成功的日志 | 150 | + // 登录成功的日志 |
| 151 | Assert.notNull(authentication.getPrincipal(), "Principal 不会为空"); | 151 | Assert.notNull(authentication.getPrincipal(), "Principal 不会为空"); |
| 152 | this.createLoginLog(username, logTypeEnum, SysLoginResultEnum.SUCCESS); | 152 | this.createLoginLog(username, logTypeEnum, SysLoginResultEnum.SUCCESS); |
| 153 | return (LoginUser) authentication.getPrincipal(); | 153 | return (LoginUser) authentication.getPrincipal(); |
| @@ -176,18 +176,18 @@ public class SysAuthServiceImpl implements SysAuthService { | @@ -176,18 +176,18 @@ public class SysAuthServiceImpl implements SysAuthService { | ||
| 176 | 176 | ||
| 177 | @Override | 177 | @Override |
| 178 | public String socialLogin(SysAuthSocialLoginReqVO reqVO, String userIp, String userAgent) { | 178 | public String socialLogin(SysAuthSocialLoginReqVO reqVO, String userIp, String userAgent) { |
| 179 | - // 使用 code 授权码,进行登陆 | 179 | + // 使用 code 授权码,进行登录 |
| 180 | AuthUser authUser = socialService.getAuthUser(reqVO.getType(), reqVO.getCode(), reqVO.getState()); | 180 | AuthUser authUser = socialService.getAuthUser(reqVO.getType(), reqVO.getCode(), reqVO.getState()); |
| 181 | Assert.notNull(authUser, "授权用户不为空"); | 181 | Assert.notNull(authUser, "授权用户不为空"); |
| 182 | 182 | ||
| 183 | - // 如果未绑定 SysSocialUserDO 用户,则无法自动登陆,进行报错 | 183 | + // 如果未绑定 SysSocialUserDO 用户,则无法自动登录,进行报错 |
| 184 | String unionId = socialService.getAuthUserUnionId(authUser); | 184 | String unionId = socialService.getAuthUserUnionId(authUser); |
| 185 | List<SysSocialUserDO> socialUsers = socialService.getAllSocialUserList(reqVO.getType(), unionId); | 185 | List<SysSocialUserDO> socialUsers = socialService.getAllSocialUserList(reqVO.getType(), unionId); |
| 186 | if (CollUtil.isEmpty(socialUsers)) { | 186 | if (CollUtil.isEmpty(socialUsers)) { |
| 187 | throw exception(AUTH_THIRD_LOGIN_NOT_BIND); | 187 | throw exception(AUTH_THIRD_LOGIN_NOT_BIND); |
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | - // 自动登陆 | 190 | + // 自动登录 |
| 191 | SysUserDO user = userService.getUser(socialUsers.get(0).getUserId()); | 191 | SysUserDO user = userService.getUser(socialUsers.get(0).getUserId()); |
| 192 | if (user == null) { | 192 | if (user == null) { |
| 193 | throw exception(USER_NOT_EXISTS); | 193 | throw exception(USER_NOT_EXISTS); |
| @@ -196,34 +196,44 @@ public class SysAuthServiceImpl implements SysAuthService { | @@ -196,34 +196,44 @@ public class SysAuthServiceImpl implements SysAuthService { | ||
| 196 | 196 | ||
| 197 | // 创建 LoginUser 对象 | 197 | // 创建 LoginUser 对象 |
| 198 | LoginUser loginUser = SysAuthConvert.INSTANCE.convert(user); | 198 | LoginUser loginUser = SysAuthConvert.INSTANCE.convert(user); |
| 199 | - // TODO 芋艿:需要改造下,增加各种登陆方式 | 199 | + // TODO 芋艿:需要改造下,增加各种登录方式 |
| 200 | loginUser.setRoleIds(this.getUserRoleIds(loginUser.getId())); // 获取用户角色列表 | 200 | loginUser.setRoleIds(this.getUserRoleIds(loginUser.getId())); // 获取用户角色列表 |
| 201 | 201 | ||
| 202 | // 绑定社交用户(更新) | 202 | // 绑定社交用户(更新) |
| 203 | socialService.bindSocialUser(loginUser.getId(), reqVO.getType(), authUser); | 203 | socialService.bindSocialUser(loginUser.getId(), reqVO.getType(), authUser); |
| 204 | 204 | ||
| 205 | - // 缓存登陆用户到 Redis 中,返回 sessionId 编号 | 205 | + // 缓存登录用户到 Redis 中,返回 sessionId 编号 |
| 206 | return userSessionService.createUserSession(loginUser, userIp, userAgent); | 206 | return userSessionService.createUserSession(loginUser, userIp, userAgent); |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | @Override | 209 | @Override |
| 210 | public String socialLogin2(SysAuthSocialLogin2ReqVO reqVO, String userIp, String userAgent) { | 210 | public String socialLogin2(SysAuthSocialLogin2ReqVO reqVO, String userIp, String userAgent) { |
| 211 | - // 使用 code 授权码,进行登陆 | 211 | + // 使用 code 授权码,进行登录 |
| 212 | AuthUser authUser = socialService.getAuthUser(reqVO.getType(), reqVO.getCode(), reqVO.getState()); | 212 | AuthUser authUser = socialService.getAuthUser(reqVO.getType(), reqVO.getCode(), reqVO.getState()); |
| 213 | Assert.notNull(authUser, "授权用户不为空"); | 213 | Assert.notNull(authUser, "授权用户不为空"); |
| 214 | 214 | ||
| 215 | - // 使用账号密码,进行登陆。 | 215 | + // 使用账号密码,进行登录。 |
| 216 | LoginUser loginUser = this.login0(reqVO.getUsername(), reqVO.getPassword()); | 216 | LoginUser loginUser = this.login0(reqVO.getUsername(), reqVO.getPassword()); |
| 217 | loginUser.setRoleIds(this.getUserRoleIds(loginUser.getId())); // 获取用户角色列表 | 217 | loginUser.setRoleIds(this.getUserRoleIds(loginUser.getId())); // 获取用户角色列表 |
| 218 | 218 | ||
| 219 | // 绑定社交用户(新增) | 219 | // 绑定社交用户(新增) |
| 220 | socialService.bindSocialUser(loginUser.getId(), reqVO.getType(), authUser); | 220 | socialService.bindSocialUser(loginUser.getId(), reqVO.getType(), authUser); |
| 221 | 221 | ||
| 222 | - // 缓存登陆用户到 Redis 中,返回 sessionId 编号 | 222 | + // 缓存登录用户到 Redis 中,返回 sessionId 编号 |
| 223 | return userSessionService.createUserSession(loginUser, userIp, userAgent); | 223 | return userSessionService.createUserSession(loginUser, userIp, userAgent); |
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | @Override | 226 | @Override |
| 227 | + public void socialBind(Long userId, SysAuthSocialBindReqVO reqVO) { | ||
| 228 | + // 使用 code 授权码,进行登录 | ||
| 229 | + AuthUser authUser = socialService.getAuthUser(reqVO.getType(), reqVO.getCode(), reqVO.getState()); | ||
| 230 | + Assert.notNull(authUser, "授权用户不为空"); | ||
| 231 | + | ||
| 232 | + // 绑定社交用户(新增) | ||
| 233 | + socialService.bindSocialUser(userId, reqVO.getType(), authUser); | ||
| 234 | + } | ||
| 235 | + | ||
| 236 | + @Override | ||
| 227 | public void logout(String token) { | 237 | public void logout(String token) { |
| 228 | // 查询用户信息 | 238 | // 查询用户信息 |
| 229 | LoginUser loginUser = userSessionService.getLoginUser(token); | 239 | LoginUser loginUser = userSessionService.getLoginUser(token); |
| @@ -269,7 +279,7 @@ public class SysAuthServiceImpl implements SysAuthService { | @@ -269,7 +279,7 @@ public class SysAuthServiceImpl implements SysAuthService { | ||
| 269 | // 重新加载 SysUserDO 信息 | 279 | // 重新加载 SysUserDO 信息 |
| 270 | SysUserDO user = userService.getUser(loginUser.getId()); | 280 | SysUserDO user = userService.getUser(loginUser.getId()); |
| 271 | if (user == null || CommonStatusEnum.DISABLE.getStatus().equals(user.getStatus())) { | 281 | if (user == null || CommonStatusEnum.DISABLE.getStatus().equals(user.getStatus())) { |
| 272 | - throw exception(TOKEN_EXPIRED); // 校验 token 时,用户被禁用的情况下,也认为 token 过期,方便前端跳转到登陆界面 | 282 | + throw exception(TOKEN_EXPIRED); // 校验 token 时,用户被禁用的情况下,也认为 token 过期,方便前端跳转到登录界面 |
| 273 | } | 283 | } |
| 274 | 284 | ||
| 275 | // 刷新 LoginUser 缓存 | 285 | // 刷新 LoginUser 缓存 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/logger/SysLoginLogService.java
| @@ -9,30 +9,30 @@ import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.logger.SysLogi | @@ -9,30 +9,30 @@ import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.logger.SysLogi | ||
| 9 | import java.util.List; | 9 | import java.util.List; |
| 10 | 10 | ||
| 11 | /** | 11 | /** |
| 12 | - * 登陆日志 Service 接口 | 12 | + * 登录日志 Service 接口 |
| 13 | */ | 13 | */ |
| 14 | public interface SysLoginLogService { | 14 | public interface SysLoginLogService { |
| 15 | 15 | ||
| 16 | /** | 16 | /** |
| 17 | - * 创建登陆日志 | 17 | + * 创建登录日志 |
| 18 | * | 18 | * |
| 19 | * @param reqVO 日志信息 | 19 | * @param reqVO 日志信息 |
| 20 | */ | 20 | */ |
| 21 | void createLoginLog(SysLoginLogCreateReqVO reqVO); | 21 | void createLoginLog(SysLoginLogCreateReqVO reqVO); |
| 22 | 22 | ||
| 23 | /** | 23 | /** |
| 24 | - * 获得登陆日志分页 | 24 | + * 获得登录日志分页 |
| 25 | * | 25 | * |
| 26 | * @param reqVO 分页条件 | 26 | * @param reqVO 分页条件 |
| 27 | - * @return 登陆日志分页 | 27 | + * @return 登录日志分页 |
| 28 | */ | 28 | */ |
| 29 | PageResult<SysLoginLogDO> getLoginLogPage(SysLoginLogPageReqVO reqVO); | 29 | PageResult<SysLoginLogDO> getLoginLogPage(SysLoginLogPageReqVO reqVO); |
| 30 | 30 | ||
| 31 | /** | 31 | /** |
| 32 | - * 获得登陆日志列表 | 32 | + * 获得登录日志列表 |
| 33 | * | 33 | * |
| 34 | * @param reqVO 列表条件 | 34 | * @param reqVO 列表条件 |
| 35 | - * @return 登陆日志列表 | 35 | + * @return 登录日志列表 |
| 36 | */ | 36 | */ |
| 37 | List<SysLoginLogDO> getLoginLogList(SysLoginLogExportReqVO reqVO); | 37 | List<SysLoginLogDO> getLoginLogList(SysLoginLogExportReqVO reqVO); |
| 38 | 38 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/logger/impl/SysLoginLogServiceImpl.java
| @@ -17,7 +17,7 @@ import javax.annotation.Resource; | @@ -17,7 +17,7 @@ import javax.annotation.Resource; | ||
| 17 | import java.util.List; | 17 | import java.util.List; |
| 18 | 18 | ||
| 19 | /** | 19 | /** |
| 20 | - * 登陆日志 Service 实现 | 20 | + * 登录日志 Service 实现 |
| 21 | */ | 21 | */ |
| 22 | @Service | 22 | @Service |
| 23 | public class SysLoginLogServiceImpl implements SysLoginLogService { | 23 | public class SysLoginLogServiceImpl implements SysLoginLogService { |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/permission/impl/SysPermissionServiceImpl.java
| @@ -280,7 +280,7 @@ public class SysPermissionServiceImpl implements SysPermissionService { | @@ -280,7 +280,7 @@ public class SysPermissionServiceImpl implements SysPermissionService { | ||
| 280 | return true; | 280 | return true; |
| 281 | } | 281 | } |
| 282 | 282 | ||
| 283 | - // 获得当前登陆的角色。如果为空,说明没有权限 | 283 | + // 获得当前登录的角色。如果为空,说明没有权限 |
| 284 | Set<Long> roleIds = SecurityFrameworkUtils.getLoginUserRoleIds(); | 284 | Set<Long> roleIds = SecurityFrameworkUtils.getLoginUserRoleIds(); |
| 285 | if (CollUtil.isEmpty(roleIds)) { | 285 | if (CollUtil.isEmpty(roleIds)) { |
| 286 | return false; | 286 | return false; |
| @@ -315,7 +315,7 @@ public class SysPermissionServiceImpl implements SysPermissionService { | @@ -315,7 +315,7 @@ public class SysPermissionServiceImpl implements SysPermissionService { | ||
| 315 | return true; | 315 | return true; |
| 316 | } | 316 | } |
| 317 | 317 | ||
| 318 | - // 获得当前登陆的角色。如果为空,说明没有权限 | 318 | + // 获得当前登录的角色。如果为空,说明没有权限 |
| 319 | Set<Long> roleIds = SecurityFrameworkUtils.getLoginUserRoleIds(); | 319 | Set<Long> roleIds = SecurityFrameworkUtils.getLoginUserRoleIds(); |
| 320 | if (CollUtil.isEmpty(roleIds)) { | 320 | if (CollUtil.isEmpty(roleIds)) { |
| 321 | return false; | 321 | return false; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/social/SysSocialService.java
| @@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil; | @@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil; | ||
| 4 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.social.SysSocialUserDO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.social.SysSocialUserDO; |
| 5 | import cn.iocoder.yudao.adminserver.modules.system.enums.user.SysSocialTypeEnum; | 5 | import cn.iocoder.yudao.adminserver.modules.system.enums.user.SysSocialTypeEnum; |
| 6 | import cn.iocoder.yudao.framework.common.exception.ServiceException; | 6 | import cn.iocoder.yudao.framework.common.exception.ServiceException; |
| 7 | +import io.swagger.models.auth.In; | ||
| 7 | import me.zhyd.oauth.model.AuthUser; | 8 | import me.zhyd.oauth.model.AuthUser; |
| 8 | 9 | ||
| 9 | import javax.validation.constraints.NotNull; | 10 | import javax.validation.constraints.NotNull; |
| @@ -52,6 +53,14 @@ public interface SysSocialService { | @@ -52,6 +53,14 @@ public interface SysSocialService { | ||
| 52 | List<SysSocialUserDO> getAllSocialUserList(Integer type, String unionId); | 53 | List<SysSocialUserDO> getAllSocialUserList(Integer type, String unionId); |
| 53 | 54 | ||
| 54 | /** | 55 | /** |
| 56 | + * 获得指定用户的社交用户列表 | ||
| 57 | + * | ||
| 58 | + * @param userId 用户编号 | ||
| 59 | + * @return 社交用户列表 | ||
| 60 | + */ | ||
| 61 | + List<SysSocialUserDO> getSocialUserList(Long userId); | ||
| 62 | + | ||
| 63 | + /** | ||
| 55 | * 绑定社交用户 | 64 | * 绑定社交用户 |
| 56 | * | 65 | * |
| 57 | * @param userId 用户编号 | 66 | * @param userId 用户编号 |
| @@ -60,4 +69,13 @@ public interface SysSocialService { | @@ -60,4 +69,13 @@ public interface SysSocialService { | ||
| 60 | */ | 69 | */ |
| 61 | void bindSocialUser(Long userId, Integer type, AuthUser authUser); | 70 | void bindSocialUser(Long userId, Integer type, AuthUser authUser); |
| 62 | 71 | ||
| 72 | + /** | ||
| 73 | + * 取消绑定社交用户 | ||
| 74 | + * | ||
| 75 | + * @param userId 用户编号 | ||
| 76 | + * @param type 社交平台的类型 {@link SysSocialTypeEnum} | ||
| 77 | + * @param unionId 社交平台的 unionId | ||
| 78 | + */ | ||
| 79 | + void unbindSocialUser(Long userId, Integer type, String unionId); | ||
| 80 | + | ||
| 63 | } | 81 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/social/impl/SysSocialServiceImpl.java
| @@ -9,7 +9,6 @@ import cn.iocoder.yudao.adminserver.modules.system.service.social.SysSocialServi | @@ -9,7 +9,6 @@ import cn.iocoder.yudao.adminserver.modules.system.service.social.SysSocialServi | ||
| 9 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | 9 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 10 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 10 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 11 | import cn.iocoder.yudao.framework.common.util.http.HttpUtils; | 11 | import cn.iocoder.yudao.framework.common.util.http.HttpUtils; |
| 12 | -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | ||
| 13 | import com.xkcoding.justauth.AuthRequestFactory; | 12 | import com.xkcoding.justauth.AuthRequestFactory; |
| 14 | import lombok.extern.slf4j.Slf4j; | 13 | import lombok.extern.slf4j.Slf4j; |
| 15 | import me.zhyd.oauth.model.AuthCallback; | 14 | import me.zhyd.oauth.model.AuthCallback; |
| @@ -18,15 +17,17 @@ import me.zhyd.oauth.model.AuthUser; | @@ -18,15 +17,17 @@ import me.zhyd.oauth.model.AuthUser; | ||
| 18 | import me.zhyd.oauth.request.AuthRequest; | 17 | import me.zhyd.oauth.request.AuthRequest; |
| 19 | import me.zhyd.oauth.utils.AuthStateUtils; | 18 | import me.zhyd.oauth.utils.AuthStateUtils; |
| 20 | import org.springframework.stereotype.Service; | 19 | import org.springframework.stereotype.Service; |
| 20 | +import org.springframework.transaction.annotation.Transactional; | ||
| 21 | 21 | ||
| 22 | import javax.annotation.Resource; | 22 | import javax.annotation.Resource; |
| 23 | import javax.validation.Valid; | 23 | import javax.validation.Valid; |
| 24 | - | ||
| 25 | import java.util.List; | 24 | import java.util.List; |
| 26 | import java.util.Objects; | 25 | import java.util.Objects; |
| 27 | 26 | ||
| 28 | import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.SOCIAL_AUTH_FAILURE; | 27 | import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.SOCIAL_AUTH_FAILURE; |
| 28 | +import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.SOCIAL_UNBIND_NOT_SELF; | ||
| 29 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 29 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 30 | +import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; | ||
| 30 | 31 | ||
| 31 | /** | 32 | /** |
| 32 | * 社交 Service 实现类 | 33 | * 社交 Service 实现类 |
| @@ -67,7 +68,7 @@ public class SysSocialServiceImpl implements SysSocialService { | @@ -67,7 +68,7 @@ public class SysSocialServiceImpl implements SysSocialService { | ||
| 67 | 68 | ||
| 68 | // 请求获取 | 69 | // 请求获取 |
| 69 | authUser = this.getAuthUser0(type, authCallback); | 70 | authUser = this.getAuthUser0(type, authCallback); |
| 70 | - // 缓存。原因是 code 有且可以使用一次。在社交登录时,当未绑定 User 时,需要绑定登陆,此时需要 code 使用两次 | 71 | + // 缓存。原因是 code 有且可以使用一次。在社交登录时,当未绑定 User 时,需要绑定登录,此时需要 code 使用两次 |
| 71 | authSocialUserRedisDAO.set(type, authCallback, authUser); | 72 | authSocialUserRedisDAO.set(type, authCallback, authUser); |
| 72 | return authUser; | 73 | return authUser; |
| 73 | } | 74 | } |
| @@ -79,18 +80,19 @@ public class SysSocialServiceImpl implements SysSocialService { | @@ -79,18 +80,19 @@ public class SysSocialServiceImpl implements SysSocialService { | ||
| 79 | } | 80 | } |
| 80 | 81 | ||
| 81 | @Override | 82 | @Override |
| 83 | + public List<SysSocialUserDO> getSocialUserList(Long userId) { | ||
| 84 | + return socialUserMapper.selectListByUserId(UserTypeEnum.ADMIN.getValue(), userId); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + @Override | ||
| 88 | + @Transactional | ||
| 82 | public void bindSocialUser(Long userId, Integer type, AuthUser authUser) { | 89 | public void bindSocialUser(Long userId, Integer type, AuthUser authUser) { |
| 83 | // 获得 unionId 对应的 SysSocialUserDO 列表 | 90 | // 获得 unionId 对应的 SysSocialUserDO 列表 |
| 84 | String unionId = getAuthUserUnionId(authUser); | 91 | String unionId = getAuthUserUnionId(authUser); |
| 85 | List<SysSocialUserDO> socialUsers = this.getAllSocialUserList(type, unionId); | 92 | List<SysSocialUserDO> socialUsers = this.getAllSocialUserList(type, unionId); |
| 86 | 93 | ||
| 87 | // 逻辑一:如果 userId 之前绑定过该 type 的其它账号,需要进行解绑 | 94 | // 逻辑一:如果 userId 之前绑定过该 type 的其它账号,需要进行解绑 |
| 88 | - List<Integer> types = SysSocialTypeEnum.getRelationTypes(type); | ||
| 89 | - List<SysSocialUserDO> oldSocialUsers = socialUserMapper.selectListByTypeAndUserId(UserTypeEnum.ADMIN.getValue(), | ||
| 90 | - types, userId); | ||
| 91 | - if (CollUtil.isNotEmpty(oldSocialUsers) && !Objects.equals(unionId, oldSocialUsers.get(0).getUnionId())) { | ||
| 92 | - socialUserMapper.deleteBatchIds(CollectionUtils.convertSet(oldSocialUsers, SysSocialUserDO::getId)); | ||
| 93 | - } | 95 | + this.unbindOldSocialUser(userId, type, unionId); |
| 94 | 96 | ||
| 95 | // 逻辑二:如果 socialUsers 指定的 userId 改变,需要进行更新 | 97 | // 逻辑二:如果 socialUsers 指定的 userId 改变,需要进行更新 |
| 96 | // 例如说,一个微信 unionId 对应了多个社交账号,结果其中有个关联了新的 userId,则其它也要跟着修改 | 98 | // 例如说,一个微信 unionId 对应了多个社交账号,结果其中有个关联了新的 userId,则其它也要跟着修改 |
| @@ -103,25 +105,52 @@ public class SysSocialServiceImpl implements SysSocialService { | @@ -103,25 +105,52 @@ public class SysSocialServiceImpl implements SysSocialService { | ||
| 103 | }); | 105 | }); |
| 104 | 106 | ||
| 105 | // 逻辑三:如果 authUser 不存在于 socialUsers 中,则进行新增;否则,进行更新 | 107 | // 逻辑三:如果 authUser 不存在于 socialUsers 中,则进行新增;否则,进行更新 |
| 106 | - SysSocialUserDO saveSocialUser = CollUtil.findOneByField(socialUsers, "openid", authUser.getUuid()); | ||
| 107 | - if (saveSocialUser == null) { | ||
| 108 | - saveSocialUser = new SysSocialUserDO(); | ||
| 109 | - saveSocialUser.setUserId(userId).setUserType(UserTypeEnum.ADMIN.getValue()); | ||
| 110 | - saveSocialUser.setType(type).setOpenid(authUser.getUuid()).setToken(authUser.getToken().getAccessToken()) | ||
| 111 | - .setUnionId(unionId).setRawTokenInfo(JsonUtils.toJsonString(authUser.getToken())); | ||
| 112 | - saveSocialUser.setNickname(authUser.getNickname()).setAvatar(authUser.getAvatar()) | ||
| 113 | - .setRawUserInfo(JsonUtils.toJsonString(authUser.getRawUserInfo())); | 108 | + SysSocialUserDO socialUser = CollUtil.findOneByField(socialUsers, "openid", authUser.getUuid()); |
| 109 | + SysSocialUserDO saveSocialUser = SysSocialUserDO.builder() // 新增和更新的通用属性 | ||
| 110 | + .token(authUser.getToken().getAccessToken()).rawUserInfo(toJsonString(authUser.getToken())) | ||
| 111 | + .nickname(authUser.getNickname()).avatar(authUser.getAvatar()).rawUserInfo(toJsonString(authUser.getRawUserInfo())) | ||
| 112 | + .build(); | ||
| 113 | + if (socialUser == null) { | ||
| 114 | + saveSocialUser.setUserId(userId).setUserType(UserTypeEnum.ADMIN.getValue()) | ||
| 115 | + .setType(type).setOpenid(authUser.getUuid()).setUnionId(unionId); | ||
| 114 | socialUserMapper.insert(saveSocialUser); | 116 | socialUserMapper.insert(saveSocialUser); |
| 115 | } else { | 117 | } else { |
| 116 | - saveSocialUser = new SysSocialUserDO().setId(saveSocialUser.getId()); | ||
| 117 | - saveSocialUser.setToken(authUser.getToken().getAccessToken()) | ||
| 118 | - .setRawTokenInfo(JsonUtils.toJsonString(authUser.getToken())); | ||
| 119 | - saveSocialUser.setNickname(authUser.getNickname()).setAvatar(authUser.getAvatar()) | ||
| 120 | - .setRawUserInfo(JsonUtils.toJsonString(authUser.getRawUserInfo())); | 118 | + saveSocialUser.setId(socialUser.getId()); |
| 121 | socialUserMapper.updateById(saveSocialUser); | 119 | socialUserMapper.updateById(saveSocialUser); |
| 122 | } | 120 | } |
| 123 | } | 121 | } |
| 124 | 122 | ||
| 123 | + @Override | ||
| 124 | + public void unbindSocialUser(Long userId, Integer type, String unionId) { | ||
| 125 | + // 获得 unionId 对应的所有 SysSocialUserDO 社交用户 | ||
| 126 | + List<SysSocialUserDO> socialUsers = this.getAllSocialUserList(type, unionId); | ||
| 127 | + if (CollUtil.isEmpty(socialUsers)) { | ||
| 128 | + return; | ||
| 129 | + } | ||
| 130 | + // 校验,是否解绑的是非自己的 | ||
| 131 | + socialUsers.forEach(socialUser -> { | ||
| 132 | + if (Objects.equals(socialUser.getUserId(), userId)) { | ||
| 133 | + throw exception(SOCIAL_UNBIND_NOT_SELF); | ||
| 134 | + } | ||
| 135 | + }); | ||
| 136 | + | ||
| 137 | + // 解绑 | ||
| 138 | + socialUserMapper.deleteBatchIds(CollectionUtils.convertSet(socialUsers, SysSocialUserDO::getId)); | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + private void unbindOldSocialUser(Long userId, Integer type, String newUnionId) { | ||
| 142 | + List<Integer> types = SysSocialTypeEnum.getRelationTypes(type); | ||
| 143 | + List<SysSocialUserDO> oldSocialUsers = socialUserMapper.selectListByTypeAndUserId(UserTypeEnum.ADMIN.getValue(), | ||
| 144 | + types, userId); | ||
| 145 | + // 如果新老的 unionId 是一致的,说明无需解绑 | ||
| 146 | + if (CollUtil.isEmpty(oldSocialUsers) || Objects.equals(newUnionId, oldSocialUsers.get(0).getUnionId())) { | ||
| 147 | + return; | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + // 解绑 | ||
| 151 | + socialUserMapper.deleteBatchIds(CollectionUtils.convertSet(oldSocialUsers, SysSocialUserDO::getId)); | ||
| 152 | + } | ||
| 153 | + | ||
| 125 | /** | 154 | /** |
| 126 | * 请求社交平台,获得授权的用户 | 155 | * 请求社交平台,获得授权的用户 |
| 127 | * | 156 | * |
| @@ -132,8 +161,8 @@ public class SysSocialServiceImpl implements SysSocialService { | @@ -132,8 +161,8 @@ public class SysSocialServiceImpl implements SysSocialService { | ||
| 132 | private AuthUser getAuthUser0(Integer type, AuthCallback authCallback) { | 161 | private AuthUser getAuthUser0(Integer type, AuthCallback authCallback) { |
| 133 | AuthRequest authRequest = authRequestFactory.get(SysSocialTypeEnum.valueOfType(type).getSource()); | 162 | AuthRequest authRequest = authRequestFactory.get(SysSocialTypeEnum.valueOfType(type).getSource()); |
| 134 | AuthResponse<?> authResponse = authRequest.login(authCallback); | 163 | AuthResponse<?> authResponse = authRequest.login(authCallback); |
| 135 | - log.info("[getAuthUser0][请求社交平台 type({}) request({}) response({})]", type, JsonUtils.toJsonString(authCallback), | ||
| 136 | - JsonUtils.toJsonString(authResponse)); | 164 | + log.info("[getAuthUser0][请求社交平台 type({}) request({}) response({})]", type, toJsonString(authCallback), |
| 165 | + toJsonString(authResponse)); | ||
| 137 | if (!authResponse.ok()) { | 166 | if (!authResponse.ok()) { |
| 138 | throw exception(SOCIAL_AUTH_FAILURE, authResponse.getMsg()); | 167 | throw exception(SOCIAL_AUTH_FAILURE, authResponse.getMsg()); |
| 139 | } | 168 | } |
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/SysSmsServiceIntegrationTest.java
| @@ -41,7 +41,7 @@ public class SysSmsServiceIntegrationTest extends BaseDbAndRedisIntegrationTest | @@ -41,7 +41,7 @@ public class SysSmsServiceIntegrationTest extends BaseDbAndRedisIntegrationTest | ||
| 41 | Integer userType = UserTypeEnum.ADMIN.getValue(); | 41 | Integer userType = UserTypeEnum.ADMIN.getValue(); |
| 42 | String templateCode = "test_01"; | 42 | String templateCode = "test_01"; |
| 43 | Map<String, Object> templateParams = MapUtil.<String, Object>builder() | 43 | Map<String, Object> templateParams = MapUtil.<String, Object>builder() |
| 44 | - .put("operation", "登陆").put("code", "1234").build(); | 44 | + .put("operation", "登录").put("code", "1234").build(); |
| 45 | // 调用 | 45 | // 调用 |
| 46 | smsService.sendSingleSms(mobile, userId, userType, templateCode, templateParams); | 46 | smsService.sendSingleSms(mobile, userId, userType, templateCode, templateParams); |
| 47 | 47 |
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/system/service/auth/SysAuthServiceImplTest.java
| @@ -236,7 +236,7 @@ public class SysAuthServiceImplTest extends BaseDbUnitTest { | @@ -236,7 +236,7 @@ public class SysAuthServiceImplTest extends BaseDbUnitTest { | ||
| 236 | when(authentication.getPrincipal()).thenReturn(loginUser); | 236 | when(authentication.getPrincipal()).thenReturn(loginUser); |
| 237 | // mock 获得 User 拥有的角色编号数组 | 237 | // mock 获得 User 拥有的角色编号数组 |
| 238 | when(permissionService.getUserRoleIds(userId, singleton(CommonStatusEnum.ENABLE.getStatus()))).thenReturn(userRoleIds); | 238 | when(permissionService.getUserRoleIds(userId, singleton(CommonStatusEnum.ENABLE.getStatus()))).thenReturn(userRoleIds); |
| 239 | - // mock 缓存登陆用户到 Redis | 239 | + // mock 缓存登录用户到 Redis |
| 240 | when(userSessionService.createUserSession(loginUser, userIp, userAgent)).thenReturn(sessionId); | 240 | when(userSessionService.createUserSession(loginUser, userIp, userAgent)).thenReturn(sessionId); |
| 241 | // 调用, 并断言异常 | 241 | // 调用, 并断言异常 |
| 242 | String login = authService.login(reqVO, userIp, userAgent); | 242 | String login = authService.login(reqVO, userIp, userAgent); |
yudao-admin-ui/src/api/login.js
| @@ -39,15 +39,15 @@ export function getCodeImg() { | @@ -39,15 +39,15 @@ export function getCodeImg() { | ||
| 39 | }) | 39 | }) |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | -// 社交登陆的跳转 | ||
| 43 | -export function socialLoginRedirect(type, redirectUri) { | 42 | +// 社交授权的跳转 |
| 43 | +export function socialAuthRedirect(type, redirectUri) { | ||
| 44 | return request({ | 44 | return request({ |
| 45 | - url: '/social-login-redirect?type=' + type + '&redirectUri=' + redirectUri, | 45 | + url: '/social-auth-redirect?type=' + type + '&redirectUri=' + redirectUri, |
| 46 | method: 'get' | 46 | method: 'get' |
| 47 | }) | 47 | }) |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | -// 社交登陆,使用 code 授权码 | 50 | +// 社交登录,使用 code 授权码 |
| 51 | export function socialLogin(type, code, state) { | 51 | export function socialLogin(type, code, state) { |
| 52 | return request({ | 52 | return request({ |
| 53 | url: '/social-login', | 53 | url: '/social-login', |
| @@ -60,7 +60,7 @@ export function socialLogin(type, code, state) { | @@ -60,7 +60,7 @@ export function socialLogin(type, code, state) { | ||
| 60 | }) | 60 | }) |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | -// 社交登陆,使用 code 授权码 + + 账号密码 | 63 | +// 社交登录,使用 code 授权码 + + 账号密码 |
| 64 | export function socialLogin2(type, code, state, username, password) { | 64 | export function socialLogin2(type, code, state, username, password) { |
| 65 | return request({ | 65 | return request({ |
| 66 | url: '/social-login2', | 66 | url: '/social-login2', |
yudao-admin-ui/src/store/modules/user.js
| @@ -47,7 +47,7 @@ const user = { | @@ -47,7 +47,7 @@ const user = { | ||
| 47 | }) | 47 | }) |
| 48 | }, | 48 | }, |
| 49 | 49 | ||
| 50 | - // 社交登陆 | 50 | + // 社交登录 |
| 51 | SocialLogin({ commit }, userInfo) { | 51 | SocialLogin({ commit }, userInfo) { |
| 52 | const code = userInfo.code | 52 | const code = userInfo.code |
| 53 | const state = userInfo.state | 53 | const state = userInfo.state |
| @@ -64,7 +64,7 @@ const user = { | @@ -64,7 +64,7 @@ const user = { | ||
| 64 | }) | 64 | }) |
| 65 | }, | 65 | }, |
| 66 | 66 | ||
| 67 | - // 社交登陆 | 67 | + // 社交登录 |
| 68 | SocialLogin2({ commit }, userInfo) { | 68 | SocialLogin2({ commit }, userInfo) { |
| 69 | const code = userInfo.code | 69 | const code = userInfo.code |
| 70 | const state = userInfo.state | 70 | const state = userInfo.state |
yudao-admin-ui/src/views/index_old.vue
| @@ -419,7 +419,7 @@ | @@ -419,7 +419,7 @@ | ||
| 419 | <li>修复表格时间为空出现的异常</li> | 419 | <li>修复表格时间为空出现的异常</li> |
| 420 | <li>添加Jackson日期反序列化时区配置</li> | 420 | <li>添加Jackson日期反序列化时区配置</li> |
| 421 | <li>调整根据用户权限加载菜单数据树形结构</li> | 421 | <li>调整根据用户权限加载菜单数据树形结构</li> |
| 422 | - <li>调整成功登陆不恢复按钮,防止多次点击</li> | 422 | + <li>调整成功登录不恢复按钮,防止多次点击</li> |
| 423 | <li>修改用户个人资料同步缓存信息</li> | 423 | <li>修改用户个人资料同步缓存信息</li> |
| 424 | <li>修复页面同时出现el-upload和Editor不显示处理</li> | 424 | <li>修复页面同时出现el-upload和Editor不显示处理</li> |
| 425 | <li>修复在角色管理页修改菜单权限偶尔未选中问题</li> | 425 | <li>修复在角色管理页修改菜单权限偶尔未选中问题</li> |
yudao-admin-ui/src/views/login.vue
| @@ -45,7 +45,7 @@ | @@ -45,7 +45,7 @@ | ||
| 45 | </template> | 45 | </template> |
| 46 | 46 | ||
| 47 | <script> | 47 | <script> |
| 48 | -import { getCodeImg,socialLoginRedirect } from "@/api/login"; | 48 | +import { getCodeImg,socialAuthRedirect } from "@/api/login"; |
| 49 | import Cookies from "js-cookie"; | 49 | import Cookies from "js-cookie"; |
| 50 | import { encrypt, decrypt } from '@/utils/jsencrypt' | 50 | import { encrypt, decrypt } from '@/utils/jsencrypt' |
| 51 | import {InfApiErrorLogProcessStatusEnum, SysUserSocialTypeEnum} from "@/utils/constants"; | 51 | import {InfApiErrorLogProcessStatusEnum, SysUserSocialTypeEnum} from "@/utils/constants"; |
| @@ -133,14 +133,14 @@ export default { | @@ -133,14 +133,14 @@ export default { | ||
| 133 | }, | 133 | }, |
| 134 | doSocialLogin(socialTypeEnum) { | 134 | doSocialLogin(socialTypeEnum) { |
| 135 | // console.log("开始Oauth登录...%o", socialTypeEnum.code); | 135 | // console.log("开始Oauth登录...%o", socialTypeEnum.code); |
| 136 | - // 设置登陆中 | 136 | + // 设置登录中 |
| 137 | this.loading = true; | 137 | this.loading = true; |
| 138 | // 计算 redirectUri | 138 | // 计算 redirectUri |
| 139 | const redirectUri = location.origin + '/social-login?type=' + socialTypeEnum.type + '&redirect=' + (this.redirect || "/"); // 重定向不能丢 | 139 | const redirectUri = location.origin + '/social-login?type=' + socialTypeEnum.type + '&redirect=' + (this.redirect || "/"); // 重定向不能丢 |
| 140 | // const redirectUri = 'http://127.0.0.1:48080/api/gitee/callback'; | 140 | // const redirectUri = 'http://127.0.0.1:48080/api/gitee/callback'; |
| 141 | // const redirectUri = 'http://127.0.0.1:48080/api/dingtalk/callback'; | 141 | // const redirectUri = 'http://127.0.0.1:48080/api/dingtalk/callback'; |
| 142 | // 进行跳转 | 142 | // 进行跳转 |
| 143 | - socialLoginRedirect(socialTypeEnum.type, encodeURIComponent(redirectUri)).then((res) => { | 143 | + socialAuthRedirect(socialTypeEnum.type, encodeURIComponent(redirectUri)).then((res) => { |
| 144 | // console.log(res.url); | 144 | // console.log(res.url); |
| 145 | window.location.href = res.data; | 145 | window.location.href = res.data; |
| 146 | }); | 146 | }); |
yudao-admin-ui/src/views/socialLogin.vue
| @@ -51,7 +51,7 @@ export default { | @@ -51,7 +51,7 @@ export default { | ||
| 51 | }, | 51 | }, |
| 52 | loading: false, | 52 | loading: false, |
| 53 | redirect: undefined, | 53 | redirect: undefined, |
| 54 | - // 社交登陆相关 | 54 | + // 社交登录相关 |
| 55 | type: undefined, | 55 | type: undefined, |
| 56 | code: undefined, | 56 | code: undefined, |
| 57 | state: undefined, | 57 | state: undefined, |
| @@ -70,7 +70,7 @@ export default { | @@ -70,7 +70,7 @@ export default { | ||
| 70 | // 重定向地址 | 70 | // 重定向地址 |
| 71 | this.redirect = this.$route.query.redirect; | 71 | this.redirect = this.$route.query.redirect; |
| 72 | debugger | 72 | debugger |
| 73 | - // 社交登陆相关 | 73 | + // 社交登录相关 |
| 74 | this.type = this.$route.query.type; | 74 | this.type = this.$route.query.type; |
| 75 | this.code = this.$route.query.code; | 75 | this.code = this.$route.query.code; |
| 76 | this.state = this.$route.query.state; | 76 | this.state = this.$route.query.state; |
yudao-admin-ui/src/views/system/loginlog/index.vue
| @@ -132,7 +132,7 @@ export default { | @@ -132,7 +132,7 @@ export default { | ||
| 132 | }).then(function() { | 132 | }).then(function() { |
| 133 | return exportLoginLog(queryParams); | 133 | return exportLoginLog(queryParams); |
| 134 | }).then(response => { | 134 | }).then(response => { |
| 135 | - this.downloadExcel(response, '登陆日志.xls'); | 135 | + this.downloadExcel(response, '登录日志.xls'); |
| 136 | }) | 136 | }) |
| 137 | } | 137 | } |
| 138 | } | 138 | } |
yudao-admin-ui/src/views/system/session/index.vue
| @@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
| 17 | <el-table-column label="会话编号" align="center" prop="id" width="300" /> | 17 | <el-table-column label="会话编号" align="center" prop="id" width="300" /> |
| 18 | <el-table-column label="登录名称" align="center" prop="username" width="100" /> | 18 | <el-table-column label="登录名称" align="center" prop="username" width="100" /> |
| 19 | <el-table-column label="部门名称" align="center" prop="deptName" width="100" /> | 19 | <el-table-column label="部门名称" align="center" prop="deptName" width="100" /> |
| 20 | - <el-table-column label="登陆地址" align="center" prop="userIp" width="100" /> | 20 | + <el-table-column label="登录地址" align="center" prop="userIp" width="100" /> |
| 21 | <el-table-column label="userAgent" align="center" prop="userAgent" :show-overflow-tooltip="true" /> | 21 | <el-table-column label="userAgent" align="center" prop="userAgent" :show-overflow-tooltip="true" /> |
| 22 | <el-table-column label="登录时间" align="center" prop="createTime" width="180"> | 22 | <el-table-column label="登录时间" align="center" prop="createTime" width="180"> |
| 23 | <template slot-scope="scope"> | 23 | <template slot-scope="scope"> |
yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java
| @@ -34,7 +34,7 @@ public class YudaoSecurityAutoConfiguration { | @@ -34,7 +34,7 @@ public class YudaoSecurityAutoConfiguration { | ||
| 34 | private SecurityProperties securityProperties; | 34 | private SecurityProperties securityProperties; |
| 35 | 35 | ||
| 36 | /** | 36 | /** |
| 37 | - * 处理用户未登陆拦截的切面的 Bean | 37 | + * 处理用户未登录拦截的切面的 Bean |
| 38 | */ | 38 | */ |
| 39 | @Bean | 39 | @Bean |
| 40 | public PreAuthenticatedAspect preAuthenticatedAspect() { | 40 | public PreAuthenticatedAspect preAuthenticatedAspect() { |
yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java
| @@ -131,7 +131,7 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap | @@ -131,7 +131,7 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap | ||
| 131 | 131 | ||
| 132 | // 设置每个请求的权限 ①:全局共享规则 | 132 | // 设置每个请求的权限 ①:全局共享规则 |
| 133 | httpSecurity.authorizeRequests() | 133 | httpSecurity.authorizeRequests() |
| 134 | - // 登陆的接口,可匿名访问 | 134 | + // 登录的接口,可匿名访问 |
| 135 | .antMatchers(api("/login")).anonymous() | 135 | .antMatchers(api("/login")).anonymous() |
| 136 | // 静态资源,可匿名访问 | 136 | // 静态资源,可匿名访问 |
| 137 | .antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js").permitAll() | 137 | .antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js").permitAll() |
yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/LoginUser.java
yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/annotations/PreAuthenticated.java
| @@ -3,9 +3,9 @@ package cn.iocoder.yudao.framework.security.core.annotations; | @@ -3,9 +3,9 @@ package cn.iocoder.yudao.framework.security.core.annotations; | ||
| 3 | import java.lang.annotation.*; | 3 | import java.lang.annotation.*; |
| 4 | 4 | ||
| 5 | /** | 5 | /** |
| 6 | - * 声明用户需要登陆 | 6 | + * 声明用户需要登录 |
| 7 | * | 7 | * |
| 8 | - * 为什么不使用 {@link org.springframework.security.access.prepost.PreAuthorize} 注解,原因是不通过时,抛出的是认证不通过,而不是未登陆 | 8 | + * 为什么不使用 {@link org.springframework.security.access.prepost.PreAuthorize} 注解,原因是不通过时,抛出的是认证不通过,而不是未登录 |
| 9 | * | 9 | * |
| 10 | * @author 芋道源码 | 10 | * @author 芋道源码 |
| 11 | */ | 11 | */ |
yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/filter/JwtAuthenticationTokenFilter.java
| @@ -63,7 +63,7 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter { | @@ -63,7 +63,7 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter { | ||
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | /** | 65 | /** |
| 66 | - * 模拟登陆用户,方便日常开发调试 | 66 | + * 模拟登录用户,方便日常开发调试 |
| 67 | * | 67 | * |
| 68 | * 注意,在线上环境下,一定要关闭该功能!!! | 68 | * 注意,在线上环境下,一定要关闭该功能!!! |
| 69 | * | 69 | * |
yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/util/SecurityFrameworkUtils.java
| @@ -84,7 +84,7 @@ public class SecurityFrameworkUtils { | @@ -84,7 +84,7 @@ public class SecurityFrameworkUtils { | ||
| 84 | /** | 84 | /** |
| 85 | * 设置当前用户 | 85 | * 设置当前用户 |
| 86 | * | 86 | * |
| 87 | - * @param loginUser 登陆用户 | 87 | + * @param loginUser 登录用户 |
| 88 | * @param request 请求 | 88 | * @param request 请求 |
| 89 | */ | 89 | */ |
| 90 | public static void setLoginUser(LoginUser loginUser, HttpServletRequest request) { | 90 | public static void setLoginUser(LoginUser loginUser, HttpServletRequest request) { |
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/filter/DemoFilter.java
| @@ -23,7 +23,7 @@ public class DemoFilter extends OncePerRequestFilter { | @@ -23,7 +23,7 @@ public class DemoFilter extends OncePerRequestFilter { | ||
| 23 | protected boolean shouldNotFilter(HttpServletRequest request) { | 23 | protected boolean shouldNotFilter(HttpServletRequest request) { |
| 24 | String method = request.getMethod(); | 24 | String method = request.getMethod(); |
| 25 | return !StrUtil.equalsAnyIgnoreCase(method, "POST", "PUT", "DELETE") // 写操作时,不进行过滤率 | 25 | return !StrUtil.equalsAnyIgnoreCase(method, "POST", "PUT", "DELETE") // 写操作时,不进行过滤率 |
| 26 | - || WebFrameworkUtils.getLoginUserId(request) == null; // 非登陆用户时,不进行过滤 | 26 | + || WebFrameworkUtils.getLoginUserId(request) == null; // 非登录用户时,不进行过滤 |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | @Override | 29 | @Override |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/auth/SysAuthService.java
| @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.security.core.service.SecurityAuthFrameworkSer | @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.security.core.service.SecurityAuthFrameworkSer | ||
| 5 | /** | 5 | /** |
| 6 | * 认证 Service 接口 | 6 | * 认证 Service 接口 |
| 7 | * | 7 | * |
| 8 | - * 提供用户的账号密码登陆、token 的校验等认证相关的功能 | 8 | + * 提供用户的账号密码登录、token 的校验等认证相关的功能 |
| 9 | * | 9 | * |
| 10 | * @author 芋道源码 | 10 | * @author 芋道源码 |
| 11 | */ | 11 | */ |