mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
Complete rewrite of the account management and related systems. Makes the architecture more modular, allowing for easier extensions and configurations.
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
import type { EmptyObject } from '../../../util/map/MapUtil';
|
|
import type { AccountStore } from '../account/util/AccountStore';
|
|
import { ensureResource, getRequiredAccount } from '../account/util/AccountUtil';
|
|
import type { JsonRepresentation } from '../InteractionUtil';
|
|
import type { JsonInteractionHandlerInput } from '../JsonInteractionHandler';
|
|
import { JsonInteractionHandler } from '../JsonInteractionHandler';
|
|
import type { ClientCredentialsStore } from './util/ClientCredentialsStore';
|
|
|
|
/**
|
|
* Handles the deletion of client credentials tokens.
|
|
*/
|
|
export class DeleteClientCredentialsHandler extends JsonInteractionHandler<EmptyObject> {
|
|
private readonly accountStore: AccountStore;
|
|
private readonly clientCredentialsStore: ClientCredentialsStore;
|
|
|
|
public constructor(accountStore: AccountStore, clientCredentialsStore: ClientCredentialsStore) {
|
|
super();
|
|
this.accountStore = accountStore;
|
|
this.clientCredentialsStore = clientCredentialsStore;
|
|
}
|
|
|
|
public async handle({ target, accountId }: JsonInteractionHandlerInput): Promise<JsonRepresentation<EmptyObject>> {
|
|
const account = await getRequiredAccount(this.accountStore, accountId);
|
|
|
|
const id = ensureResource(account.clientCredentials, target.path);
|
|
|
|
// This also deletes it from the account
|
|
await this.clientCredentialsStore.delete(id, account);
|
|
|
|
return { json: {}};
|
|
}
|
|
}
|