Merge pull request #724 from paulhenry46/userlogout-api-hook

feat: implement existing hooks onBeforeLogout and onAfterLogout + new plugin API method
This commit is contained in:
Linus Rath
2026-08-01 23:09:39 +02:00
committed by GitHub
6 changed files with 43 additions and 8 deletions
+7 -1
View File
@@ -67,6 +67,7 @@ const PERM_PER_METHOD: Record<string, Permission | null> = {
// user
'user.getAccounts': 'account:read',
'user.getIdentities': 'identity:read',
'user.logout': 'auth:emit',
// admin
'admin.getConfig': 'admin:config',
'admin.getAllConfig': 'admin:config',
@@ -177,7 +178,7 @@ interface AccountResponse {
function doUserGetAccounts(): AccountResponse[] {
const state = useAccountStore.getState();
// ws remove sensitive fields from the account entries before returning to the plugin
// we remove sensitive fields from the account entries before returning to the plugin
const accounts = state.accounts.map((account) => ({
id: account.id,
label: account.label,
@@ -197,6 +198,10 @@ function doUserGetIdentities(): Identity[] {
return useIdentityStore.getState().identities;
}
async function doUserLogout(): Promise<void>{
return useAuthStore.getState().logout();
}
// ─── http.post (same-origin /api/*) ───────────────────────────
/**
@@ -786,6 +791,7 @@ export async function dispatchApiCall(
case 'user.getAccounts': return doUserGetAccounts();
case 'user.getIdentities': return doUserGetIdentities();
case 'user.logout' : return doUserLogout();
case 'admin.getConfig': return adminGet(plugin.id, args[0] as string);
case 'admin.getAllConfig': return adminGetAll(plugin.id);