Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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

Expand Down
29 changes: 22 additions & 7 deletions packages/backend/src/server/api/endpoints/i/revoke-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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,
});
}
}
});
}
Expand Down
6 changes: 4 additions & 2 deletions packages/frontend/src/pages/settings/plugin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
Loading