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 = False

Frontend 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"
    }
  }
}

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

  1. User submits email address
  2. Backend generates a signed sesame token
  3. Email sent with verification link
  4. User clicks link → /accounts/code-verify/?sesame=<token>
  5. 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_data

Social Authentication (OAuth)

OAuth 2.0 authentication with external providers.

Supported Providers

ProviderStatusScopes
Google✅ Configuredprofile, email
GitHub✅ Configureduser, repo, read:org
LinkedIn✅ Configuredr_basicprofile, r_emailaddress
Facebook✅ Configuredemail, 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: /projects

Configuration

# 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

  1. User signs up
  2. Backend sends verification email with link
  3. User clicks link → /auth/verify-email/{key}
  4. Frontend calls verification API
  5. 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

On this page