Skip to main content
The NCT Hub platform uses Supabase Auth for user authentication with support for email/password, OAuth providers, one-time passwords (OTP), and session management. The system is designed to handle club member authentication, external integrations, and secure API access.

Authentication Flow

  1. User signs in via Supabase Auth
  2. Supabase validates credentials against database
  3. Client receives session token
  4. Subsequent requests include session token for RLS

Sign Up

Basic Email/Password Sign Up

Client Component

Sign In

Email/Password Sign In

OAuth Sign In

Client Component:

Sign Out

Multi-Factor Authentication (MFA)

Enable TOTP MFA

Verify MFA Enrollment

MFA Challenge During Sign In

Verify MFA Code

Session Management

Get Current Session

Get Current User

Refresh Session

Password Reset

Request Password Reset

Reset Password

Email Verification

Resend Verification Email

Cross-App Authentication

The platform supports token-based authentication across different apps using @ncthub/auth/cross-app.

Generate Cross-App Token

Verify Cross-App Token

Middleware Authentication

Protect routes using Next.js middleware:

Protected Server Component

Client-Side Authentication

useUser Hook

Usage

Identity Linking

Link multiple auth providers to same account:

Best Practices

✅ DO

  1. Always check authentication server-side
  2. Use edge runtime for auth routes
  3. Redirect after authentication
  4. Handle errors gracefully
  5. Implement MFA for sensitive operations

❌ DON’T

  1. Don’t trust client-side auth state alone
  2. Don’t expose sensitive data in auth redirects
  3. Don’t store passwords
  4. Don’t use createAdminClient() for auth operations

External Resources