Login Methods
Guide to all supported login methods including email/password, magic links, social authentication, and password reset
Login Methods
The authentication system supports multiple login methods.
Email + Password
Standard authentication using email address and password.
Backend Configuration
ACCOUNT_AUTHENTICATION_METHOD = "email"
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USERNAME_REQUIRED = FalseFrontend Implementation
// hooks/use-auth.ts
const { login } = useAuth();
await login(email, password);API Request
POST /_allauth/browser/v1/auth/login
Content-Type: application/json
X-CSRFToken: <csrf_token>
{
"email": "user@example.com",
"password": "password123"
}Response
{
"meta": {
"is_authenticated": true
},
"data": {
"user": {
"id": 1,
"email": "user@example.com",
"display": "user@example.com"
}
}
}Magic Link Authentication
Passwordless login via email link using django-sesame.
API Endpoint
POST /api/v1/auth/magic-link/
Content-Type: application/json
{
"email": "user@example.com"
}Flow
- User submits email address
- Backend generates a signed sesame token
- Email sent with verification link
- User clicks link →
/accounts/code-verify/?sesame=<token> - Backend validates token, creates session, redirects to app
Backend Implementation
# apps/accounts/api/magic_link.py
@router.post("/magic-link/")
def authenticate_user(request, data: MagicLinkSchema):
email = data.email
link_data = User.auth_manager.create_magic_link(email, request)
return link_dataSocial Authentication (OAuth)
OAuth 2.0 authentication with external providers.
Supported Providers
| Provider | Status | Scopes |
|---|---|---|
| ✅ Configured | profile, email | |
| GitHub | ✅ Configured | user, repo, read:org |
| ✅ Configured | r_basicprofile, r_emailaddress | |
| ✅ Configured | email, public_profile |
Frontend Implementation
// hooks/use-auth.ts
const { socialLogin } = useAuth();
// Redirects to OAuth provider
socialLogin("google", `${window.location.origin}/auth/callback/google`);OAuth Flow
User clicks "Login with Google"
│
▼
Redirect to: /accounts/google/login/?next=/projects
│
▼
Google OAuth consent screen
│
▼
Callback to: /accounts/google/login/callback/
│
▼
Allauth creates/links account, sets session
│
▼
Redirect to: /projectsConfiguration
# config/settings.py
SOCIALACCOUNT_PROVIDERS = {
"google": {
"SCOPE": ["profile", "email"],
"AUTH_PARAMS": {"access_type": "online"},
},
"github": {
"SCOPE": ["user", "repo", "read:org"],
},
}Password Reset
Request Reset
POST /_allauth/browser/v1/auth/password/request
Content-Type: application/json
{
"email": "user@example.com"
}Complete Reset
POST /_allauth/browser/v1/auth/password/reset
Content-Type: application/json
{
"key": "<reset_token_from_email>",
"password": "newPassword123!"
}Frontend Implementation
const { requestPasswordReset, resetPassword } = useAuth();
// Request reset email
await requestPasswordReset(email);
// Complete reset (on reset page)
await resetPassword(key, newPassword);Email Verification
Email verification is mandatory before account access.
Verification Flow
- User signs up
- Backend sends verification email with link
- User clicks link →
/auth/verify-email/{key} - Frontend calls verification API
- Account activated, user logged in
API Request
POST /_allauth/browser/v1/auth/email/verify
Content-Type: application/json
{
"key": "<verification_key>"
}Resend Verification
const { resendVerificationEmail } = useAuth();
await resendVerificationEmail(email);Signup
API Request
POST /_allauth/browser/v1/auth/signup
Content-Type: application/json
X-CSRFToken: <csrf_token>
{
"email": "newuser@example.com",
"password": "securePassword123!"
}Response (Verification Required)
{
"data": {
"flows": [
{ "id": "verify_email", "is_pending": true }
]
}
}Frontend Implementation
const { signup, pendingFlow } = useAuth();
await signup(email, password);
if (pendingFlow?.id === "verify_email") {
router.push("/verify-email-sent");
}Last updated on