Overview
Studley AI uses Supabase authentication to provide secure account management with email verification, session handling, and multi-factor authentication (MFA) support.Creating an Account
Enter Your Information
Fill out the registration form:
- First Name: Your first name
- Last Name: Your last name
- Email: A valid email address
- Password: At least 6 characters
- Confirm Password: Must match your password
Agree to Terms
Check the box to agree to the Terms of Service and Privacy Policy. This is required to create an account.
Submit Registration
Click “Create Account” to submit your registration. The system will:
- Create your Supabase Auth account
- Insert your profile into the
userstable - Send a welcome email to your inbox
Verify Your Email
After registration, you’ll be shown a verification screen. Check your email inbox for a 6-digit verification code.Enter the 6-digit code in the verification form and click “Verify Email”.
Welcome emails are sent asynchronously and won’t block the signup process. If you don’t receive the email, check your spam folder.
Logging In
Submit Login
Click “Sign In” to authenticate. The system will:
- Verify your credentials with Supabase Auth
- Check if MFA is enabled on your account
- Create a session if successful
Complete MFA (If Enabled)
If you have MFA enabled:
- The system creates an MFA challenge
- You’ll be prompted to enter your 6-digit authenticator code
- Enter the code from your authenticator app (Google Authenticator, Authy, etc.)
- Click “Verify Code” to complete authentication
Alternative Login Methods
In addition to email/password, you can sign in using:- Google OAuth: Click “Continue with Google” to authenticate using your Google account
- Clever SSO: For students and educators, click “Login with Clever” for single sign-on
Email Verification
Verification Flow
Email verification happens immediately after signup:- Code Generation: Supabase generates a 6-digit OTP (one-time password)
- Email Delivery: The code is sent to your registered email address
- Code Entry: Enter the code on the verification page within the time limit
- Account Activation: Once verified, your account is fully activated
Verification Requirements
- Verification codes are time-sensitive
- You must verify your email before accessing most features
- Unverified accounts may have limited functionality
If you close the verification page, you can request a new code by attempting to log in again.
Session Management
Session Creation
When you log in successfully, Studley AI creates a secure session:- Technology: JWT (JSON Web Tokens) signed with HS256
- Duration: 7 days from login
- Storage: Secure HTTP-only cookie named
session - Cookie Settings:
httpOnly: true- Prevents JavaScript accesssecure: true(production) - HTTPS onlysameSite: lax- CSRF protectionmaxAge: 7 days
Session Data
Your session token contains:Session Validation
The session is automatically validated:- Client-side: On every page load
- Server-side: On every API request
- Middleware: Protects dashboard routes (
/dashboard/*)
Session Expiration
Sessions expire after 7 days. When your session expires:- You’re automatically redirected to
/login - Your previous page is saved for redirect after login
- You’ll need to log in again to continue
Logging Out
To end your session:Multi-Factor Authentication (MFA)
MFA Support
Studley AI supports TOTP (Time-based One-Time Password) authentication:- Compatible with Google Authenticator, Authy, 1Password, etc.
- Adds an extra layer of security to your account
- Required after password verification when enabled
MFA Login Flow
- Enter email and password as normal
- System checks for verified TOTP factors
- If MFA is enabled, a challenge is created
- Enter your 6-digit authenticator code
- System verifies the code and grants access
MFA setup is currently managed through Supabase. Contact support if you need to enable or disable MFA on your account.
Security Best Practices
- Strong Passwords: Use at least 6 characters (longer is better)
- Unique Passwords: Don’t reuse passwords from other sites
- Enable MFA: Add two-factor authentication for extra security
- Secure Devices: Log out from shared or public computers
- Monitor Activity: Check your recent activity regularly
Authentication API Endpoints
Signup
- Endpoint:
POST /api/auth/signup - Body:
{ email, firstName, lastName, password } - Response:
{ success: true, user: { id, email, firstName, lastName } }
Login
- Endpoint:
POST /api/auth/login - Body:
{ email, password }or{ email, password, mfaCode, challengeId } - Response:
{ success: true, user: { id, email, name } }or{ mfaRequired: true, challengeId }
Verify Email
- Endpoint:
POST /api/auth/verify - Body:
{ email, otp } - Response:
{ success: true }
Logout
- Endpoint:
POST /api/auth/logout - Response:
{ success: true }
Troubleshooting
Can’t receive verification email?
- Check your spam/junk folder
- Verify you entered the correct email address
- Wait a few minutes and try again
- Contact support if the issue persists
Forgot password?
- Currently, password reset is handled through email
- Contact support at [email protected] for assistance
MFA code not working?
- Ensure your device’s time is synchronized
- Try the previous or next code (accounts for clock drift)
- Contact support if you’ve lost access to your authenticator
Session expired unexpectedly?
- Sessions last 7 days - you may need to log in again
- Clear your browser cookies and try logging in fresh
- Check if you’re using private/incognito mode (cookies don’t persist)