Files
vexplor/backend-node/src/routes/authRoutes.ts
DDD1542 d43f0821ed refactor: Update authentication handling in authRoutes and useAuth hook
- Replaced the middleware `checkAuthStatus` with the `AuthController.checkAuthStatus` method in the authentication routes for improved clarity and structure.
- Simplified token validation logic in the `useAuth` hook by removing unnecessary checks for expired tokens, allowing the API client to handle token refresh automatically.
- Enhanced logging for authentication checks to provide clearer insights into the authentication flow and potential issues.
- Adjusted the handling of user authentication status to ensure consistency and reliability in user state management.

This refactor streamlines the authentication process and improves the overall maintainability of the authentication logic.
2026-03-05 11:51:05 +09:00

56 lines
1.2 KiB
TypeScript

// 인증 API 라우터
// Phase 2-1B: 핵심 인증 API 구현
import { Router } from "express";
import { AuthController } from "../controllers/authController";
const router = Router();
/**
* GET /api/auth/status
* 인증 상태 확인 API
* 기존 Java ApiLoginController.checkAuthStatus() 포팅
*/
router.get("/status", AuthController.checkAuthStatus);
/**
* POST /api/auth/login
* 로그인 API
* 기존 Java ApiLoginController.login() 포팅
*/
router.post("/login", AuthController.login);
/**
* GET /api/auth/me
* 현재 사용자 정보 조회 API
* 기존 Java ApiLoginController.getCurrentUser() 포팅
*/
router.get("/me", AuthController.getCurrentUser);
/**
* POST /api/auth/logout
* 로그아웃 API
* 기존 Java ApiLoginController.logout() 포팅
*/
router.post("/logout", AuthController.logout);
/**
* POST /api/auth/refresh
* JWT 토큰 갱신 API
*/
router.post("/refresh", AuthController.refreshToken);
/**
* POST /api/auth/signup
* 공차중계 회원가입 API
*/
router.post("/signup", AuthController.signup);
/**
* POST /api/auth/switch-company
* WACE 관리자 전용: 다른 회사로 전환
*/
router.post("/switch-company", AuthController.switchCompany);
export default router;