core: fix oauth id

This commit is contained in:
undefined committed 2025-04-29 12:04:04 +08:00
1 parent 401bb505c2
commit 0f7961d675
4 files changed
+15 -3

No files matched your search

+12
View File
@@ -603,4 +603,16 @@ export const coreScripts: MigrationScript[] = [
});
return true;
},
async function _93_94(ctx) {
await ctx.inject(['oauth'], async (c) => {
await c.oauth.coll.deleteMany({ _id: { $type: 'string' } });
const docs = await c.oauth.coll.find({ id: { $type: 'number' as any } }).toArray();
const op = c.oauth.coll.initializeUnorderedBulkOp();
for (const doc of docs) {
op.find({ _id: doc._id }).updateOne({ id: doc.id.toString() });
}
if (op.length) await op.execute();
});
return true;
},
];
+1 -1
View File
@@ -47,7 +47,7 @@ export default class LoginWithGithubService extends Service {
.set('Accept', 'application/vnd.github.v3+json')
.set('Authorization', `token ${t}`);
const ret = {
_id: userInfo.body.id,
_id: userInfo.body.id.toString(),
email: userInfo.body.email,
bio: userInfo.body.bio,
uname: [userInfo.body.name, userInfo.body.login].filter((i) => i),
+1 -1
View File
@@ -60,7 +60,7 @@ export default class GoogleOAuthService extends Service {
await TokenModel.del(state, TokenModel.TYPE_OAUTH);
this.response.redirect = s.redirect;
return {
_id: payload.sub,
_id: payload.sub.toString(),
email: payload.email,
uname: [`${payload.given_name} ${payload.family_name}`, payload.name],
viewLang: payload.locale.replace('-', '_'),
+1 -1
View File
@@ -40,7 +40,7 @@ export default class TelegramService extends Service {
id, first_name, last_name, username, photo_url,
} = parsed;
const ret = {
_id: id,
_id: id.toString(),
email: `${id}@telegram.local`,
bio: '',
uname: [`${first_name} ${last_name}`, username, `telegram${id.toString()}`].filter((i) => i),