feat: Implement authentication system with token refresh and initial instructor dashboard with course management.
This commit is contained in:
parent
0eb9b522f6
commit
ab3124628c
11 changed files with 1053 additions and 93 deletions
|
|
@ -211,6 +211,33 @@ export const authService = {
|
|||
baseURL: config.public.apiBaseUrl as string,
|
||||
body: data
|
||||
});
|
||||
},
|
||||
|
||||
async refreshToken(currentRefreshToken: string): Promise<{ token: string; refreshToken: string }> {
|
||||
const config = useRuntimeConfig();
|
||||
const useMockData = config.public.useMockData as boolean;
|
||||
|
||||
if (useMockData) {
|
||||
// Mock: return new tokens
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
return {
|
||||
token: 'mock-new-jwt-token-' + Date.now(),
|
||||
refreshToken: 'mock-new-refresh-token-' + Date.now()
|
||||
};
|
||||
}
|
||||
|
||||
if (!currentRefreshToken) {
|
||||
throw new Error('No refresh token available');
|
||||
}
|
||||
|
||||
// Real API
|
||||
const response = await $fetch<{ token: string; refreshToken: string }>('/api/auth/refresh', {
|
||||
method: 'POST',
|
||||
baseURL: config.public.apiBaseUrl as string,
|
||||
body: { refreshToken: currentRefreshToken }
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue