enhance: プラグイン削除時にアクセストークンも削除する (#12167)

* (enhance) プラグイン削除時にトークンも削除

* update changelog
This commit is contained in:
かっこかり 2023-10-28 07:54:06 +09:00 committed by GitHub
parent 8a2309ba7d
commit e5ff8d8445
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 9 deletions

View file

@ -23,6 +23,7 @@
- 外部サイトでの実装が必要です。詳細は Misskey Hub をご覧ください
https://misskey-hub.net/docs/advanced/publish-on-your-website.html
- Feat: AiScript関数`Mk:nyaize()`が追加されました
- Enhance: プラグインを削除した際には、使用されていたアクセストークンも同時に削除されるようになりました
- Fix: 投稿フォームでのユーザー変更がプレビューに反映されない問題を修正
- Fix: ユーザーページの ノート > ファイル付き タブにリプライが表示されてしまう

View file

@ -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<typeof meta, typeof paramDef> { // 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,
});
}
}
});
}

View file

@ -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();
});