mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: add support for unlink oauth account
This commit is contained in:
2 files changed
+10
-3
No files matched your search
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user