File tree 4 files changed +48
-9
lines changed
4 files changed +48
-9
lines changed Original file line number Diff line number Diff line change @@ -19,19 +19,19 @@ const tobeIdentified = [
19
19
"liandmin" ,
20
20
"sunshineliu6" ,
21
21
"Huzhixin00" ,
22
- "Leah-Luo" ,
22
+ // "Leah-Luo",
23
23
"HackBL" ,
24
- "mozro.0327 " ,
24
+ "mozro0327 " ,
25
25
"liucy0417" ,
26
26
"watermelonDrip" ,
27
27
"wonderful1234" ,
28
- "SWUFEzyf" ,
28
+ // "SWUFEzyf",
29
29
"suffocatingly0" ,
30
30
"christ36" ,
31
31
"awarmdevil" ,
32
32
"NchuYJ" ,
33
33
"zc-githubs" ,
34
- "paopaohua" ,
34
+ // "paopaohua",
35
35
"Critsu" ,
36
36
"Placeholder" ,
37
37
"Levix" ,
@@ -114,6 +114,25 @@ const tobeIdentified = [
114
114
115
115
"angusgenius" ,
116
116
"lilyzhaoyilu" ,
117
+ "FlorenceLLL" ,
118
+ "zjsj" ,
119
+ "andyyxw" ,
120
+ "pkuphy" ,
121
+ "zhangjihu0" ,
122
+ "wz-hub" ,
123
+ "bmxbmx3" ,
124
+ "davont" ,
125
+ "Lizhao-Liu " ,
126
+ "terrylijiayang" ,
127
+ "shizukanaskytree" ,
128
+ "taozi-taozi" ,
129
+ "wanyongtao1988" ,
130
+ "LzdFeiFei" ,
131
+ "angusgenius" ,
132
+ "lilyzhaoyilu" ,
133
+ "ningali" ,
134
+ "WIN0624" ,
135
+ "Gjts" ,
117
136
] ;
118
137
119
138
module . exports = {
@@ -149,6 +168,9 @@ module.exports = {
149
168
{
150
169
login : "15399618796" ,
151
170
} ,
171
+ {
172
+ login : "Xeraphinite" ,
173
+ } ,
152
174
] . concat (
153
175
tobeIdentified . map ( ( name ) => ( {
154
176
login : name ,
Original file line number Diff line number Diff line change 1
1
const fetch = require ( "node-fetch" ) ;
2
+ const { Octokit } = require ( "@octokit/rest" ) ;
2
3
const { encrypt, decrypt } = require ( "../utils/crypto" ) ;
3
4
const { fail } = require ( "../utils/request" ) ;
4
5
const { secret, db, clientId } = require ( "../config/index" ) ;
@@ -62,11 +63,18 @@ module.exports = async function checkAuth(ctx, next) {
62
63
...user ,
63
64
pay : ! ! db . find ( ( q ) => q . login === user . login ) ,
64
65
} ;
65
- // TODO: 如果不在组织中,自动邀请进 Github 组织
66
- // see #1 https://octokit.github.io/rest.js/v18#orgs-check-membership
67
- // see #2 https://github.com/octokit/octokit.js
68
- // see #3 https://github.com/thundergolfer/automated-github-organization-invites/blob/bb1bb3d42a330716f4dd5c49256245e4bde27489/web_app.rb
69
- ctx . session . user = u ;
66
+ try {
67
+ const octokit = new Octokit ( { auth : process . env . token } ) ;
68
+
69
+ octokit . rest . teams . addOrUpdateMembershipForUserInOrg ( {
70
+ org : "leetcode-pp" ,
71
+ team_slug : "91algo-4" ,
72
+ username : user . login ,
73
+ } ) ;
74
+ } catch ( err ) {
75
+ console . log ( "自动邀请失败:" , err ) ;
76
+ }
77
+
70
78
ctx . cookies . set (
71
79
"token" ,
72
80
encrypt ( Buffer . from ( JSON . stringify ( u ) , "utf8" ) ) ,
Original file line number Diff line number Diff line change 10
10
},
11
11
"dependencies" : {
12
12
"@koa/cors" : " ^3.1.0" ,
13
+ "@octokit/rest" : " ^18.5.3" ,
13
14
"debug" : " ^4.1.1" ,
14
15
"koa" : " ^2.7.0" ,
15
16
"koa-bodyparser" : " ^4.2.1" ,
Original file line number Diff line number Diff line change
1
+ const { Octokit } = require ( "@octokit/rest" ) ;
2
+ const octokit = new Octokit ( { auth : process . env . token } ) ;
3
+
4
+ octokit . rest . teams . addOrUpdateMembershipForUserInOrg ( {
5
+ org : "leetcode-pp" ,
6
+ team_slug : "91algo-4" ,
7
+ username : "rfhklwt" ,
8
+ } ) ;
You can’t perform that action at this time.
0 commit comments