refactor: resolve #7139
This commit is contained in:
@@ -10,7 +10,6 @@ import signin from '../common/signin';
|
||||
import { fetchMeta } from '../../../misc/fetch-meta';
|
||||
import { Users, UserProfiles } from '../../../models';
|
||||
import { ILocalUser } from '../../../models/entities/user';
|
||||
import { ensure } from '../../../prelude/ensure';
|
||||
|
||||
function getUserToken(ctx: Koa.Context) {
|
||||
return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
|
||||
@@ -41,12 +40,12 @@ router.get('/disconnect/github', async ctx => {
|
||||
return;
|
||||
}
|
||||
|
||||
const user = await Users.findOne({
|
||||
const user = await Users.findOneOrFail({
|
||||
host: null,
|
||||
token: userToken
|
||||
}).then(ensure);
|
||||
});
|
||||
|
||||
const profile = await UserProfiles.findOne(user.id).then(ensure);
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
|
||||
delete profile.integrations.github;
|
||||
|
||||
@@ -227,12 +226,12 @@ router.get('/gh/cb', async ctx => {
|
||||
return;
|
||||
}
|
||||
|
||||
const user = await Users.findOne({
|
||||
const user = await Users.findOneOrFail({
|
||||
host: null,
|
||||
token: userToken
|
||||
}).then(ensure);
|
||||
});
|
||||
|
||||
const profile = await UserProfiles.findOne(user.id).then(ensure);
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
|
||||
await UserProfiles.update(user.id, {
|
||||
integrations: {
|
||||
|
Reference in New Issue
Block a user