Auth: Email Login Flow#747
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis pull request adds authentication via magic links and email invitations with SMTP configuration support. It introduces new authentication endpoints, token generation/verification services, email templates, configuration settings, and comprehensive test coverage for the new flows. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Frontend
participant API
participant AuthService
participant EmailService
participant Database
User->>Frontend: Request magic link login
Frontend->>API: POST /auth/magic-link (email)
API->>Database: Lookup user by email
Database-->>API: User record
API->>AuthService: Generate magic link token
AuthService-->>API: Signed JWT token
API->>EmailService: Send magic link email
EmailService-->>User: Email with sign-in link
API-->>Frontend: Success response
User->>Frontend: Click link from email
Frontend->>API: GET /auth/magic-link/verify?token=...
API->>AuthService: Verify magic link token
AuthService-->>API: Decoded payload (email)
API->>Database: Lookup user by email
Database-->>API: User record
API->>Database: Activate user (if inactive)
Database-->>API: Updated user
API->>AuthService: Generate access JWT with project context
AuthService-->>API: Access token
API-->>Frontend: Access token + HTTP-only cookies
Frontend-->>User: Authenticated session
sequenceDiagram
actor User
participant Admin
participant API
participant AuthService
participant EmailService
participant Database
Admin->>API: POST /projects/{id}/users (add new user)
API->>Database: Commit new project user
Database-->>API: Success
API->>Database: Fetch organization & project
Database-->>API: Org/project records
API->>AuthService: Generate invite token
AuthService-->>API: Signed JWT token (org_id, project_id)
API->>EmailService: Generate & send invitation email
EmailService-->>User: Email with acceptance link
API-->>Admin: Success (user list)
User->>API: GET /auth/invite/verify?token=...
API->>AuthService: Verify invite token
AuthService-->>API: Decoded payload (email, org_id, project_id)
API->>Database: Lookup user by email
Database-->>API: User record
API->>Database: Activate user (if inactive)
Database-->>API: Updated user
API->>AuthService: Generate access JWT with org/project context
AuthService-->>API: Access token
API-->>User: Access token + HTTP-only cookies
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~28 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…4DevAI/kaapi-backend into feat/email-validation-flow
…ctTech4DevAI/kaapi-backend into feat/email-validation-flow
Issue: ProjectTech4DevAI/kaapi-frontend#115
Summary:
POST /auth/magic-link→ email →GET /auth/magic-link/verify).services/auth.pyfor both invite and magic link tokens.Checklist
Before submitting a pull request, please ensure that you mark these task.
fastapi run --reload app/main.pyordocker compose upin the repository root and test.Summary by CodeRabbit
New Features
Documentation
Chores