Commit Graph

948 Commits

Author SHA1 Message Date
Haitao Pan
becb692c2f fix(login): enable TOTP forwarding in API route and update documentation
The login API route was not receiving or forwarding TOTP codes from the
frontend, causing MFA login failures.

Changes:
1. Added 'totp' field to LoginPayload interface in routes/api/auth/login.ts
2. Updated handleLogin() to receive and forward TOTP codes to backend
3. Added logging for TOTP presence in login attempts
4. Updated LOGIN_FLOW.md to clarify the single-step login flow with optional TOTP

Login Flow:
- Frontend pre-checks MFA status via GET /api/auth/mfa/status
- If MFA enabled, frontend shows TOTP input field
- User submits email, password, and optionally TOTP code
- Backend receives and validates TOTP if provided
- Backend returns success or appropriate error

This implements the correct single-step login flow where users provide
credentials and TOTP together, as documented in LOGIN_FLOW.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 15:44:32 +08:00
Haitao Pan
f83c71f5f8 cleanup(dashboard-fresh): remove Next.js App Router and clean TypeScript config
Major cleanup to align with Fresh/Deno standard structure:

Deleted:
- app/ directory - Next.js 13+ App Router (38 files, 3795 deletions)
  This includes all Next.js page routes and API routes that were conflicting
  with Fresh's routes/ structure

Updated:
- tsconfig.json - Removed Next.js specific configuration:
  * Removed "plugins": [{ "name": "next" }]
  * Removed "app" from include paths
  * Removed ".next/types/**/*.ts" from include
  * Added Fresh-specific paths: routes, islands, api, static

Preserved:
- routes/login.tsx - Fresh page route for login
- routes/api/auth/login.ts - Fresh API route
- islands/LoginForm.tsx - Client-side login component (already fixed)
- api/ - Utility functions for content handling
- static/styles/globals.css - Global styles (correct location)

Known Issues (pending migration):
- 17+ component files use Next.js specific imports and features:
  * components/Navbar.tsx - uses next/link, next/navigation
  * components/Footer.tsx - uses Next.js imports
  * components/home/*.tsx - multiple files with Next.js dependencies
  * components/iac/*.tsx - Infrastructure components with Next.js code

These components need to be:
1. Migrated to Fresh/Deno compatible code (replace Next.js APIs)
2. Or moved to islands/ directory with Preact hooks
3. Or replaced with Fresh-native solutions

Next steps: Migrate problematic components to Fresh/Deno standards

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 15:18:42 +08:00
Haitao Pan
b035192cd2 refactor(dashboard-fresh): remove Next.js migrated code, keep Fresh standard structure
Removed migrated Next.js code that conflicts with Fresh/Deno project structure:

Deleted:
- app/(auth)/login/ - Next.js login pages and components
- app/(auth)/register/ - Next.js registration pages
- app/(auth)/email-verification/ - Next.js email verification pages
- app/api/auth/ - Next.js API routes (login, register, mfa, session, verify-email)
- app/api/admin/ - Next.js admin API routes
- app/api/mail/ - Next.js mail API routes
- app/api/agent/, app/api/askai/, app/api/rag/, app/api/task/, app/api/users/ - Other Next.js API routes

The Fresh project now uses the correct structure:
- routes/login.tsx - Login page (uses islands/LoginForm.tsx)
- routes/api/auth/login.ts - Login API with multi-step MFA support
- islands/LoginForm.tsx - Client-side login form component

This eliminates the duplicate login implementations that were causing
mfaToken verification failures and ensures clean separation between
Fresh routes and client islands.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 15:04:03 +08:00
Haitao Pan
9a5b95cfb2 fix(login): remove mandatory TOTP validation to fix MFA token flow
Allow users to submit login form without TOTP code first, then require
TOTP based on backend response (error: "mfa_code_required"). This fixes
the issue where frontend blocked all submissions when MFA was enabled.

Changes:
- Removed mandatory TOTP validation in both Fresh and Next.js versions
- Only validate TOTP format if provided (6 digits)
- Keep error handling logic to show TOTP input when backend requires it

Fixes mfaToken verification failure during login flow.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 14:51:31 +08:00
Haitao Pan
ca7669af2e docs(login): update LOGIN_FLOW.md and clarify MFA setup flow
- Remove needMfa field from login API responses
- MFA setup redirection now only occurs in registration flow
- Registration always redirects to /panel/account?NeedSetupMfa=1
- Update documentation to reflect simplified login flow
- Clarify that login API returns error: 'mfa_code_required' instead of needMfa: true

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 14:24:30 +08:00
Haitao Pan
d2dafabf65 feat(api): improve MFA detection and update MFA routes to async config
- Fix MFA detection logic to recognize mfa_code_required error
  - Remove strict mfaToken requirement when needMfa is determined by error code
  - Update mfa/status route to use async getAuthUrl() from runtime-loader
  - Update mfa/verify route to use async getAuthUrl() from runtime-loader
  - Add comprehensive structured logging across all MFA endpoints
  - Add timeout control (10s) for backend requests
  - Improve error handling with detailed console output
  - Add LOGIN_FLOW.md documentation in Chinese

  This completes the migration of all MFA-related endpoints to the new Deno
  native runtime configuration system.
2025-11-05 13:28:42 +08:00
Haitao Pan
66721ea54a feat(dashboard-fresh): implement multi-step login API and Deno native runtime config
- Add step-based login flow (check_email, login, verify_mfa)
  - Create Deno native runtime configuration loader
  - Fix all component imports to include file extensions
  - Add comprehensive API documentation
2025-11-05 13:07:58 +08:00
Haitao Pan
2a3e80c44f refactor(dashboard-fresh): extract user menu into standalone component
- Create islands/UserMenu.tsx with self-contained user menu functionality
  - Refactor islands/Navbar.tsx to use UserMenu component
  - Support both desktop and mobile layouts with single component
2025-11-05 09:18:56 +08:00
Haitao Pan
7edf4cb564 update: dashboard-fresh/docs/API_ENDPOINTS_TODO.md 2025-11-05 08:47:38 +08:00
Haitao Pan
12a914ee49 feat(api): migrate MFA authentication endpoints and add favicon
API Routes Migration:
   - Migrated /api/auth/mfa/status endpoint for checking MFA status
   - Migrated /api/auth/mfa/setup endpoint for TOTP provisioning
   - Migrated /api/auth/mfa/verify endpoint for code verification
   - Migrated /api/auth/mfa/disable endpoint for disabling MFA
   - All routes properly handle cookies (session and MFA tokens)
   - Implemented proper error handling and status codes

   Bug Fixes:
   - Added favicon.ico to static folder (fixes 404 error)
   - Updated fresh.gen.ts with new route manifests

   Migration Details:
   - Converted Next.js route handlers to Fresh Handlers pattern
   - Updated cookie management from Next.js cookies() to Deno's getCookies()
   - Changed Response handling from NextResponse to standard Response
   - Maintained compatibility with existing authentication flow
   - Proxies requests to backend account service API
2025-11-05 08:27:03 +08:00
Haitao Pan
d37f2dab42 feat(dashboard-fresh): improve homepage and navbar
- Enhanced homepage visuals: larger headings, gradient theme, improved CTA animations, and better text readability
- Added dynamic navbar offset using CSS variable (--app-shell-nav-offset)
- Fixed language toggle and routing consistency
- Introduced new components: Hero, CtaButtons, ShowcaseCarousel
- Resolved Preact version mismatch and <Head> rendering issues
2025-11-05 08:06:56 +08:00
Haitao Pan
dd6bb68d25 feat(dashboard-fresh): migrate panel routes to Fresh
- Panel Infrastructure:
  - Add lib/userSession.ts for user session utilities
  - Create islands/panel/Sidebar.tsx with navigation and MFA
  warnings
  - Create islands/panel/Header.tsx with user info and role badges
  - Create islands/panel/PanelLayout.tsx as layout wrapper
  - Add routes/panel/index.tsx as dashboard home page
  - Add routes/panel/account.tsx for account settings
  - Add routes/panel/mail.tsx for mail service (placeholder)
2025-11-04 23:37:58 +08:00
Haitao Pan
b542a0ae17 feat(auth): migrate register pages to Fresh/Deno
- /routes/register.tsx - Registration page with email verification
  - /islands/RegisterForm.tsx - Multi-step registration with email code
2025-11-04 22:50:56 +08:00
Haitao Pan
ae5e09be76 feat(auth): migrate login page to Fresh with AuthLayout and MFA support
- Migrate /components/auth/AuthLayout.tsx to Preact
 - Create /routes/login.tsx using Fresh handlers and SSR
 - Create /islands/LoginForm.tsx with MFA (TOTP) support
2025-11-04 22:26:05 +08:00
Haitao Pan
613dda4ad1 fix(navbar): restore original design and integrate Fresh migration
Changes:
  - Create /islands/Navbar.tsx with Preact/signals state management
  - Fix translucent background (bg-white/85) and backdrop-blur effect
  - Restore high-contrast branding (text-gray-900 for logo/title)
  - Fix menu item spacing (gap-6) and hover effects (hover:text-brand)
  - Add proper alignment for search bar, auth buttons, and icons
  - Integrate language selector and release channel icon (🧪)

Testing:
  - Homepage (/) loads successfully (200 OK)
  - Navbar demo (/navbar-demo) works correctly
2025-11-04 21:40:29 +08:00
shenlan
f6703962f2 fix: align fresh navbar theming (#646) 2025-11-04 20:18:35 +08:00
shenlan
0ad9888b0a feat: refine fresh homepage layout (#645) 2025-11-04 18:31:55 +08:00
Haitao Pan
9c877ceb3c feat(dashboard-fresh): migrate and integrate dashboard source
- Add fresh app structure (auth, tenant, mail, insight, docs, panel)
- Include CMS content, API routes, scripts, and config
- Migrate UI components, themes, and extensions to fresh runtime
2025-11-04 18:06:21 +08:00
shenlan
d6299f8ca4 docs: align dashboard plan with fresh deno migration (#644) 2025-11-04 12:57:02 +08:00
Haitao Pan
8096601118 fix(account): add timeout and email validation for verification sending 2025-11-04 09:38:15 +08:00
shenlan
1e01279678 feat: enable mail demo preview and fix extension import (#643) 2025-11-03 07:56:18 +08:00
shenlan
9fc3765c38 Add email verification auth page (#642) 2025-11-02 23:09:51 +08:00
shenlan
42dc37a45c Simplify verification step notice (#641) 2025-11-02 22:43:00 +08:00
shenlan
9dcb8eab79 Improve registration feedback and verification flow (#640) 2025-11-02 19:34:26 +08:00
shenlan
e1fa949d68 Keep registration code inputs enabled (#639) 2025-11-02 18:44:34 +08:00
shenlan
db07406186 Fix runtime loader search path for sit env (#638) 2025-11-02 18:11:33 +08:00
shenlan
22d1907828 Merge pull request #637 from Cloud-Neutral/codex/refactor-runtime-loader-for-server-only 2025-11-02 15:42:57 +08:00
shenlan
350f6b92a4 refactor runtime loader to server module 2025-11-02 15:41:55 +08:00
root
1d4e858348 update prod runtime config and cleanup: adjust .gitignore, remove account-export.yaml 2025-11-02 12:07:13 +08:00
shenlan
333421a8ec Limit SMTP send duration with request-scoped timeouts (#636) 2025-11-02 11:54:59 +08:00
shenlan
0a255ed1b8 Simplify runtime config loading (#635) 2025-11-02 11:51:46 +08:00
Haitao Pan
3a6a7f62f7 add docs/account-test-cases.md 2025-11-02 11:50:12 +08:00
shenlan
bdc3dc405f Fix runtime env detection for SIT domains (#634) 2025-11-02 11:00:56 +08:00
shenlan
4a03a0e783 Detect implicit TLS when auto mode uses port 465 (#633) 2025-11-02 10:47:20 +08:00
Haitao Pan
9090040451 merged: refactor-project-for-environment-auto-detection 2025-11-02 10:42:26 +08:00
shenlan
c9c9cd255a feat: add runtime config loader 2025-11-02 10:38:06 +08:00
Haitao Pan
5600460751 Adjust SIT environment configuration: runtime-service-config + dev Nginx 2025-11-02 10:35:37 +08:00
shenlan
175eecfb84 Disable caching in SIT Nginx config (#631) 2025-11-02 09:06:57 +08:00
shenlan
bb84b65845 feat: align svc.plus gateway layering (#630) 2025-11-02 07:11:11 +08:00
shenlan
6575449e0d fix(next): rewrite API trailing slashes (#629) 2025-11-01 23:52:34 +08:00
shenlan
9af421d6e3 fix(next): rewrite trailing api slashes in config (#628) 2025-11-01 23:44:51 +08:00
shenlan
3e98c22655 fix(next): rewrite API trailing slashes (#627) 2025-11-01 23:25:55 +08:00
Haitao Pan
163ae0f5c4 fix(next): disable trailingSlash to restore API route matching for /api/auth/* 2025-11-01 23:14:12 +08:00
shenlan
91b32e8a48 Fix register send proxy handler (#626) 2025-11-01 22:41:26 +08:00
shenlan
8bc62f088c feat: show real-time register validation hints (#625) 2025-11-01 22:14:59 +08:00
shenlan
cde2ccdf80 Fix account service API URL joining (#624) 2025-11-01 21:53:15 +08:00
shenlan
9daf5a3378 Refine registration flow with verification gate (#623) 2025-11-01 21:34:35 +08:00
Haitao Pan
164eda0fe8 add scripts/install_stalwart_mailserver.sh 2025-11-01 20:27:32 +08:00
shenlan
32784d74b6 Rename register resend endpoint to send (#622) 2025-11-01 20:25:37 +08:00
shenlan
a898b95248 Refine register messaging and avoid redundant resend call (#621) 2025-11-01 18:57:17 +08:00