generated from pascalmartineau/wp-skeleton
feat: better user switching code
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 1m0s
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 1m0s
This commit is contained in:
@@ -3,17 +3,14 @@ import { defineEventHandler } from "h3";
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
const response = await useGraphqlMutation("userSwitchBack");
|
||||
|
||||
if (response.errors?.length) {
|
||||
throw new Error(response.errors[0]?.message || "Switch back failed");
|
||||
throw new Error(response.errors[0]?.message);
|
||||
}
|
||||
|
||||
await clearUserSession(event);
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
catch (error) {
|
||||
const message = error instanceof Error ? error.message : "Switch back failed";
|
||||
const message = error instanceof Error ? error.message : "Échec du retour à l'utilisateur précédent";
|
||||
return { success: false, message };
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user