From e5ff8d8445668eb2bcd1e9fa38a2d0041b6ca678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sat, 28 Oct 2023 07:54:06 +0900 Subject: [PATCH] =?UTF-8?q?enhance:=20=E3=83=97=E3=83=A9=E3=82=B0=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E5=89=8A=E9=99=A4=E6=99=82=E3=81=AB=E3=82=A2=E3=82=AF?= =?UTF-8?q?=E3=82=BB=E3=82=B9=E3=83=88=E3=83=BC=E3=82=AF=E3=83=B3=E3=82=82?= =?UTF-8?q?=E5=89=8A=E9=99=A4=E3=81=99=E3=82=8B=20(#12167)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * (enhance) プラグイン削除時にトークンも削除 * update changelog --- CHANGELOG.md | 1 + .../server/api/endpoints/i/revoke-token.ts | 29 ++++++++++++++----- .../frontend/src/pages/settings/plugin.vue | 6 ++-- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67ec9ee8e7..304cc0ebe6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - 外部サイトでの実装が必要です。詳細は Misskey Hub をご覧ください https://misskey-hub.net/docs/advanced/publish-on-your-website.html - Feat: AiScript関数`Mk:nyaize()`が追加されました +- Enhance: プラグインを削除した際には、使用されていたアクセストークンも同時に削除されるようになりました - Fix: 投稿フォームでのユーザー変更がプレビューに反映されない問題を修正 - Fix: ユーザーページの ノート > ファイル付き タブにリプライが表示されてしまう diff --git a/packages/backend/src/server/api/endpoints/i/revoke-token.ts b/packages/backend/src/server/api/endpoints/i/revoke-token.ts index 8e2f271005..e8bb282533 100644 --- a/packages/backend/src/server/api/endpoints/i/revoke-token.ts +++ b/packages/backend/src/server/api/endpoints/i/revoke-token.ts @@ -18,8 +18,12 @@ export const paramDef = { type: 'object', properties: { tokenId: { type: 'string', format: 'misskey:id' }, + token: { type: 'string' }, }, - required: ['tokenId'], + anyOf: [ + { required: ['tokenId'] }, + { required: ['token'] }, + ], } as const; @Injectable() @@ -29,13 +33,24 @@ export default class extends Endpoint { // eslint- private accessTokensRepository: AccessTokensRepository, ) { super(meta, paramDef, async (ps, me) => { - const tokenExist = await this.accessTokensRepository.exist({ where: { id: ps.tokenId } }); + if (ps.tokenId) { + const tokenExist = await this.accessTokensRepository.exist({ where: { id: ps.tokenId } }); - if (tokenExist) { - await this.accessTokensRepository.delete({ - id: ps.tokenId, - userId: me.id, - }); + if (tokenExist) { + await this.accessTokensRepository.delete({ + id: ps.tokenId, + userId: me.id, + }); + } + } else if (ps.token) { + const tokenExist = await this.accessTokensRepository.exist({ where: { token: ps.token } }); + + if (tokenExist) { + await this.accessTokensRepository.delete({ + token: ps.token, + userId: me.id, + }); + } } }); } diff --git a/packages/frontend/src/pages/settings/plugin.vue b/packages/frontend/src/pages/settings/plugin.vue index 4a2d8d600e..d72d8d00f3 100644 --- a/packages/frontend/src/pages/settings/plugin.vue +++ b/packages/frontend/src/pages/settings/plugin.vue @@ -77,9 +77,11 @@ import { definePageMetadata } from '@/scripts/page-metadata.js'; const plugins = ref(ColdDeviceStorage.get('plugins')); -function uninstall(plugin) { +async function uninstall(plugin) { ColdDeviceStorage.set('plugins', plugins.value.filter(x => x.id !== plugin.id)); - os.success(); + await os.apiWithDialog('i/revoke-token', { + token: plugin.token, + }); nextTick(() => { unisonReload(); });