enhance: プラグイン削除時にアクセストークンも削除する (#12167)
* (enhance) プラグイン削除時にトークンも削除 * update changelog
This commit is contained in:
parent
8a2309ba7d
commit
e5ff8d8445
3 changed files with 27 additions and 9 deletions
|
@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue