Files
gridpilot.gg/apps/website/app/actions/logoutAction.ts
2026-01-14 10:51:05 +01:00

26 lines
829 B
TypeScript

'use server';
import { Result } from '@/lib/contracts/Result';
import { LogoutMutation } from '@/lib/mutations/auth/LogoutMutation';
/**
* Server action for logout
*
* Performs the logout mutation and returns a Result.
* Follows the write boundary contract: all writes enter through server actions.
* Returns Result type for type-safe error handling.
*
* Note: This action does NOT redirect. The caller should handle redirect
* based on the Result to maintain proper error handling flow.
*/
export async function logoutAction(): Promise<Result<void, string>> {
const mutation = new LogoutMutation();
const result = await mutation.execute();
if (result.isErr()) {
console.error('Logout action failed:', result.getError());
return Result.err(result.getError());
}
return Result.ok(undefined);
}