feat: Introduce user authentication and registration features with login, registration pages, and an authentication service.
This commit is contained in:
parent
11d714c632
commit
6d59ec06bf
3 changed files with 254 additions and 0 deletions
|
|
@ -193,5 +193,37 @@ export const authService = {
|
|||
baseURL: config.public.apiBaseUrl as string,
|
||||
body: { token, password }
|
||||
});
|
||||
},
|
||||
|
||||
async registerInstructor(data: RegisterInstructorRequest): Promise<void> {
|
||||
const config = useRuntimeConfig();
|
||||
const useMockData = config.public.useMockData as boolean;
|
||||
|
||||
if (useMockData) {
|
||||
// Mock: simulate registration
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
return;
|
||||
}
|
||||
|
||||
// Real API
|
||||
await $fetch('/api/auth/register-instructor', {
|
||||
method: 'POST',
|
||||
baseURL: config.public.apiBaseUrl as string,
|
||||
body: data
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Register Instructor Request
|
||||
export interface RegisterInstructorRequest {
|
||||
username: string;
|
||||
email: string;
|
||||
password: string;
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
prefix: {
|
||||
en: string;
|
||||
th: string;
|
||||
};
|
||||
phone: string;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue