mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Full rework of account management
Complete rewrite of the account management and related systems. Makes the architecture more modular, allowing for easier extensions and configurations.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
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: {}};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user