core: add support for unlink oauth account

This commit is contained in:
undefined committed 2025-08-28 01:06:43 +08:00
1 parent f18efc6bbb
commit 0ddcee7336
2 files changed
+10 -3

No files matched your search

+7
View File
@@ -259,6 +259,13 @@ class HomeSecurityHandler extends Handler {
await this.ctx.oauth.providers[platform].get.call(this);
}
@param('platform', Types.String)
async postUnlinkAccount({ }, platform: string) {
if (!this.ctx.oauth.providers[platform]) throw new ValidationError('platform');
await this.ctx.oauth.unbind(platform, this.user._id);
this.back();
}
@param('tokenDigest', Types.String)
async postDeleteToken({ }, tokenDigest: string) {
const sessions = await token.getSessionListByUid(this.user._id);
+3 -3
View File
@@ -50,7 +50,7 @@ export default class OauthModel extends Service {
async [Context.init]() {
await this.ctx.db.ensureIndexes(this.coll,
// { key: { platform: 1, id: 1 }, name: 'platform_id', unique: true },
{ key: { platform: 1, id: 1 }, name: 'platform_id', unique: true },
{ key: { uid: 1, platform: 1 }, name: 'uid_platform' },
);
}
@@ -70,8 +70,8 @@ export default class OauthModel extends Service {
return res?.uid;
}
async unbind(platform: string, id: string, uid: number) {
await this.coll.deleteOne({ platform, id, uid });
async unbind(platform: string, uid: number) {
await this.coll.deleteOne({ platform, uid });
}
async list(uid: number) {