Browse Source

feat(auth): implement session management and authentication middleware

- Added constants for session management in `auth.ts`.
- Created an authentication guard middleware in `02.auth-guard.ts` to protect API routes.
- Introduced caching mechanism in `00.cache.ts` and `01.context.ts` for improved performance.
- Developed user authentication context in `context.ts` to manage user sessions.
- Implemented cookie handling functions in `cookie.ts` for session management.
- Added error handling for authentication in `errors.ts`.
- Enhanced user authentication logic in `index.ts` with session creation and validation.
- Created captcha service for user registration and login in `captcha` directory.
- Established configuration management with error handling in `config` directory.
- Added utility functions for admin role verification and API route allowlisting.
- Implemented rate limiting to prevent abuse of API endpoints.
beauty-auth
npmrun 5 days ago
parent
commit
f9e8be933e
  1. 2
      app/pages/auth/index.vue
  2. BIN
      packages/drizzle-pkg/db.sqlite

2
app/pages/auth/index.vue

@ -25,6 +25,7 @@ const loginError = ref('')
const registerError = ref('')
const loginLoading = ref(false)
const registerLoading = ref(false)
const { refresh } = useAuthSession()
async function fetchCaptcha() {
captcha.loading = true
@ -53,6 +54,7 @@ async function handleLogin() {
captchaAnswer: captcha.answer,
},
})
await refresh(true)
await navigateTo('/')
} catch (e: any) {
loginError.value = e?.data?.statusMessage || e?.message || '登录失败'

BIN
packages/drizzle-pkg/db.sqlite

Binary file not shown.
Loading…
Cancel
Save