1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-03 11:26:14 +02:00
This commit is contained in:
syuilo
2021-12-09 23:58:30 +09:00
parent 0abe2dfee0
commit c69b72e199
573 changed files with 3318 additions and 3318 deletions

View File

@@ -92,7 +92,7 @@ router.get('/connect/github', async ctx => {
const params = {
redirect_uri: `${config.url}/api/gh/cb`,
scope: ['read:user'],
state: uuid()
state: uuid(),
};
redisClient.set(userToken, JSON.stringify(params));
@@ -107,13 +107,13 @@ router.get('/signin/github', async ctx => {
const params = {
redirect_uri: `${config.url}/api/gh/cb`,
scope: ['read:user'],
state: uuid()
state: uuid(),
};
ctx.cookies.set('signin_with_github_sid', sessid, {
path: '/',
secure: config.url.startsWith('https'),
httpOnly: true
httpOnly: true,
});
redisClient.set(sessid, JSON.stringify(params));
@@ -155,7 +155,7 @@ router.get('/gh/cb', async ctx => {
const { accessToken } = await new Promise<any>((res, rej) =>
oauth2!.getOAuthAccessToken(code, {
redirect_uri
redirect_uri,
}, (err, accessToken, refresh, result) => {
if (err) {
rej(err);
@@ -167,7 +167,7 @@ router.get('/gh/cb', async ctx => {
}));
const { login, id } = await getJson('https://api.github.com/user', 'application/vnd.github.v3+json', 10 * 1000, {
'Authorization': `bearer ${accessToken}`
'Authorization': `bearer ${accessToken}`,
});
if (!login || !id) {
ctx.throw(400, 'invalid session');
@@ -219,7 +219,7 @@ router.get('/gh/cb', async ctx => {
}));
const { login, id } = await getJson('https://api.github.com/user', 'application/vnd.github.v3+json', 10 * 1000, {
'Authorization': `bearer ${accessToken}`
'Authorization': `bearer ${accessToken}`,
});
if (!login || !id) {
@@ -229,7 +229,7 @@ router.get('/gh/cb', async ctx => {
const user = await Users.findOneOrFail({
host: null,
token: userToken
token: userToken,
});
const profile = await UserProfiles.findOneOrFail(user.id);
@@ -241,8 +241,8 @@ router.get('/gh/cb', async ctx => {
accessToken: accessToken,
id: id,
login: login,
}
}
},
},
});
ctx.body = `GitHub: @${login} を、Misskey: @${user.username} に接続しました!`;
@@ -250,7 +250,7 @@ router.get('/gh/cb', async ctx => {
// Publish i updated event
publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, {
detail: true,
includeSecrets: true
includeSecrets: true,
}));
}
});