QNH-309 and QNH-311. Create Register Page and Login Page - #15
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implementasi infrastruktur autentikasi frontend dan dua halaman pertama
Sprint 9: Register dan Login. PR ini mencakup fondasi yang dibutuhkan oleh
semua task auth selanjutnya (AUTH-03, AUTH-04) — Axios instance, Auth Context,
route guards, service layer — sekaligus dua page pertama yang menggunakannya.
Jira Ticket
Ticket: AUTH-01, AUTH-02
Type of Change
Changes Made
src/api/axiosInstance.ts— Axios instance terpusat dengan baseURL dariVITE_API_URL, default headers,withCredentials: true, dan interceptoruntuk attach Bearer token dari sessionStorage
src/types/auth.ts— Shared TypeScript interfaces untuk auth domain(AuthUser, RegisterPayload, LoginPayload, dll)
src/services/authService.ts— Abstraksi HTTP call untuk register, login,dan logout; komponen tidak memanggil Axios secara langsung
src/contexts/AuthContext.tsx— React Context untuk auth state (user, token,isAuthenticated) dengan sessionStorage sebagai bridge survive-refresh
src/hooks/useAuth.ts— Custom hook untuk consume AuthContextsrc/routes/PublicRoute.tsx— Route guard: redirect ke /dashboard jika sudahauthenticated
src/routes/ProtectedRoute.tsx— Route guard: redirect ke /login jika belumauthenticated
src/pages/RegisterPage.tsx— Form register (name, email, phone, password,password_confirmation) dengan per-field error handling untuk 422 dan generic
error untuk 500
src/pages/LoginPage.tsx— Form login (email, password) dengan role-basedredirect ke /dashboard, error handling 401 dan 422
src/App.tsx— Updated dengan BrowserRouter, AuthProvider, dan routestructure (public + protected)
src/tests/pages/RegisterPage.test.tsx— 6 unit testssrc/tests/pages/LoginPage.test.tsx— 7 unit tests.env.example— Dokumentasi environment variableVITE_API_URLHow to Test
.env.exampleke.env.localdan setVITE_API_URLke URL backendnpm run devdan buka/register/logindengansuccess message
/login, login dengan credentials yang baru didaftarkan — verifikasiredirect ke
/dashboard/loginsaat sudah authenticated — verifikasi redirect ke/dashboard/dashboardsaat belum authenticated — verifikasi redirect ke/loginnpm run testScreenshots (if applicable)
Checklist
Notes for Reviewer
Auth mode saat ini masih menggunakan Bearer Token (sessionStorage bridge)
karena implementasi dikerjakan sebelum keputusan migrasi ke Sanctum
Cookie-based Session (ADR-006). Revisi ke cookie-based akan dilakukan di
sprint ticket terpisah setelah OpenAPI contract diupdate oleh BE.