From 6d59ec06bf1437e02c0223b2f6cf7fd5eab71d6f Mon Sep 17 00:00:00 2001 From: Missez Date: Mon, 19 Jan 2026 16:52:37 +0700 Subject: [PATCH] feat: Introduce user authentication and registration features with login, registration pages, and an authentication service. --- frontend_management/pages/login.vue | 6 + frontend_management/pages/register.vue | 216 +++++++++++++++++++ frontend_management/services/auth.service.ts | 32 +++ 3 files changed, 254 insertions(+) create mode 100644 frontend_management/pages/register.vue diff --git a/frontend_management/pages/login.vue b/frontend_management/pages/login.vue index 679f5012..c7603bd8 100644 --- a/frontend_management/pages/login.vue +++ b/frontend_management/pages/login.vue @@ -57,6 +57,12 @@

ทดสอบ: admin@elearning.local / instructor@elearning.local

+
+ ยังไม่มีบัญชี? + + ลงทะเบียนเป็นผู้สอน + +
diff --git a/frontend_management/pages/register.vue b/frontend_management/pages/register.vue new file mode 100644 index 00000000..3f8d4f9b --- /dev/null +++ b/frontend_management/pages/register.vue @@ -0,0 +1,216 @@ + + + diff --git a/frontend_management/services/auth.service.ts b/frontend_management/services/auth.service.ts index c7579709..bd3b0011 100644 --- a/frontend_management/services/auth.service.ts +++ b/frontend_management/services/auth.service.ts @@ -193,5 +193,37 @@ export const authService = { baseURL: config.public.apiBaseUrl as string, body: { token, password } }); + }, + + async registerInstructor(data: RegisterInstructorRequest): Promise { + 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; +}