Complete Story 1-1 and fix TypeScript issues
Add TypeScript strict mode and typecheck tasks to monorepo infrastructure. Fix E2E test @payload-config alias and frontend TypeScript errors. - Add tsconfig.json to backend with strict mode and path aliases - Add typecheck task to Turborepo and all packages - Fix @payload-config alias for E2E tests and dev server - Add setToken method to AuthService for middleware use - Fix implicit any types in Footer.astro and Header.astro - Remove invalid typescript config from astro.config.mjs
This commit is contained in:
@@ -61,6 +61,7 @@ export class AuthService {
|
||||
}
|
||||
|
||||
async logout(): Promise<void> {
|
||||
const tokenForRequest = this.token;
|
||||
this.token = null;
|
||||
if (typeof window !== 'undefined') {
|
||||
localStorage.removeItem('payload-token');
|
||||
@@ -68,17 +69,25 @@ export class AuthService {
|
||||
|
||||
// Optional: Call logout endpoint
|
||||
try {
|
||||
const headers: Record<string, string> = {
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
if (tokenForRequest) {
|
||||
headers['Authorization'] = `Bearer ${tokenForRequest}`;
|
||||
}
|
||||
await fetch(`${PAYLOAD_URL}/api/users/logout`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...(this.token && { 'Authorization': `Bearer ${this.token}` }),
|
||||
},
|
||||
headers,
|
||||
});
|
||||
} catch (error) {
|
||||
// Ignore logout errors
|
||||
}
|
||||
}
|
||||
|
||||
setToken(token: string): void {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
async getCurrentUser(): Promise<User | null> {
|
||||
if (!this.token) return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user