Files
gridpilot.gg/apps/website/lib/mutations/auth/LogoutMutation.ts
Marc Mintel 1b0a1f4aee
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 7m11s
Contract Testing / contract-snapshot (pull_request) Has been skipped
view data fixes
2026-01-24 23:29:55 +01:00

27 lines
765 B
TypeScript

/**
* Logout Mutation
*
* Framework-agnostic mutation for logout operations.
* Called from Server Actions.
*
* Pattern: Server Action → Mutation → Service → API Client
*/
import { Result } from '@/lib/contracts/Result';
import { AuthService } from '@/lib/services/auth/AuthService';
export class LogoutMutation {
async execute(): Promise<Result<void, string>> {
try {
const authService = new AuthService();
const result = await authService.logout();
if (result.isErr()) {
return Result.err(result.getError().message);
}
return Result.ok(undefined);
} catch (error) {
const errorMessage = error instanceof Error ? error.message : 'Logout failed';
return Result.err(errorMessage);
}
}
}