Skip to main content

Overview

The Studley AI account system allows you to manage your personal information, customize your profile, and control your account settings. Your profile data is stored in both the users and profiles tables for optimal performance.

User Profiles

Profile Data Structure

Your profile contains:
  • First Name: Your given name
  • Last Name: Your family name
  • Full Name: Automatically combined from first and last name
  • Email: Your verified email address
  • Avatar URL: Profile picture stored in Vercel Blob
  • Created At: Account creation timestamp

Database Tables

users table:
  • Stores core user information
  • Contains id, email, first_name, last_name, name, created_at
  • Primary source for authentication
profiles table:
  • Stores extended profile data
  • Contains id, full_name, username, avatar_url, updated_at, created_at
  • Used for display purposes and customization

Accessing Profile Settings

1

Open Settings

Navigate to /dashboard/settings or click the settings icon in the dashboard sidebar.
2

View Profile

Your current profile information will be loaded automatically from:
  • Supabase Auth (email)
  • users table (first name, last name)
  • profiles table (avatar URL)

Updating Personal Information

1

Navigate to Personal Information

In the Settings page, find the “Personal Information” section with the user icon.
2

Edit Your Name

Update your first name and/or last name in the input fields. Both fields are required (marked with *).
3

Save Changes

Click “Update Profile” to save your changes. The system will:
  • Validate that both names are provided
  • Update the users table with new values
  • Update the profiles table for display consistency
  • Show a success message when complete
Profile changes sync immediately across all dashboard components. Other users will see your updated name on shared content.

Avatar Upload

Uploading a Profile Picture

1

Navigate to Profile Picture Section

In Settings, find the “Profile Picture” section at the top.
2

Click Upload

Click the “Upload New Photo” button to open your file picker.
3

Select Image

Choose an image file from your device:
  • Supported formats: JPG, PNG, GIF
  • Maximum size: 5MB
  • Validation: Must be a valid image file
4

Upload Process

The system will:
  1. Validate file size and type
  2. Upload to Vercel Blob storage via /api/upload-avatar
  3. Receive a permanent URL for the image
  4. Update the profiles table with the new avatar_url
  5. Display your new avatar immediately

Avatar Display

Your avatar is displayed:
  • In the dashboard sidebar
  • On profile dropdown menus
  • Next to your library items
  • On shared content as the creator
If you haven’t uploaded an avatar, your initials are displayed in a colored circle (first letter of first name or email).

Removing an Avatar

Currently, avatars can only be replaced, not removed. Upload a new image to replace your current avatar.

Email Management

Viewing Your Email

Your email address is displayed in the “Email Address” section of Settings. It’s shown as read-only.

Changing Your Email

Email changes require support assistance for security:
  1. Contact support at [email protected]
  2. Provide verification of your identity
  3. Support will update your email and send confirmation
Direct email changes are disabled to prevent account takeover. This security measure protects your account and content.

Password Management

Changing Your Password

1

Navigate to Change Password

In Settings, scroll to the “Change Password” section with the lock icon.
2

Enter Current Password

Type your current password in the first field. Click the eye icon to show/hide your password.
3

Enter New Password

Type your new password:
  • Minimum length: 6 characters
  • Use a strong, unique password
  • Avoid common words or patterns
4

Confirm New Password

Re-type your new password in the confirmation field. It must match exactly.
5

Update Password

Click “Update Password”. The system will:
  • Validate password requirements
  • Update your Supabase Auth credentials
  • Clear the password fields
  • Show a success message
After changing your password, you’ll remain logged in on your current device. Other devices will require login with the new password.

Account Settings Features

Profile Dropdown

Click your avatar in the sidebar to access:
  • Quick view of your name and email
  • Link to Settings page
  • Logout button

Real-time Updates

When you update your profile:
  1. Changes save to the database
  2. A userProfileUpdated event is dispatched
  3. Dashboard components listen for this event
  4. UI updates immediately without page refresh

Success and Error Messages

The Settings page shows animated notifications:
  • Success (green): Changes saved successfully
  • Error (red): Validation or save errors
  • Auto-dismiss: Messages disappear after 3 seconds

Database Schema

users table

CREATE TABLE users (
  id UUID PRIMARY KEY,
  email TEXT NOT NULL,
  first_name TEXT,
  last_name TEXT,
  name TEXT,
  created_at TIMESTAMPTZ DEFAULT NOW()
);

profiles table

CREATE TABLE profiles (
  id UUID PRIMARY KEY,
  full_name TEXT,
  username TEXT UNIQUE,
  avatar_url TEXT,
  updated_at TIMESTAMPTZ DEFAULT NOW(),
  created_at TIMESTAMPTZ DEFAULT NOW()
);

Row Level Security (RLS)

Both tables have RLS policies:
  • SELECT: Users can read their own profile
  • UPDATE: Users can update their own profile
  • INSERT: Users can create their own profile

Auto-Profile Creation

When you sign up:
  1. Supabase Auth creates your authentication record
  2. The signup API inserts your record into users table:
    • id: Matches your auth user ID
    • email: Your verified email
    • first_name, last_name: From signup form
    • name: Combined full name
    • created_at: Current timestamp
  3. Profile is created automatically on first settings access

Account Deletion

Deletion Process

To delete your account:
1

Open Danger Zone

Navigate to Settings and scroll to the “Danger Zone” section at the bottom (red border).
2

Click Delete Account

Click the “Delete Account” button to open the deletion modal.
3

Contact Support

Account deletion requires support verification:
  • Click “Email Support” in the modal
  • This opens your email client with a pre-filled subject
  • Alternatively, email [email protected] directly
4

Verification

Support will:
  1. Verify your identity
  2. Confirm deletion request
  3. Delete all your data (profile, library items, settings)
  4. Send confirmation email
Account deletion is permanent and cannot be undone. All your quizzes, flashcards, study guides, and settings will be permanently deleted.

API Endpoints

Get Current User

  • Endpoint: GET /api/auth/user
  • Response: { user: { id, username, fullName, isVerified } }

Upload Avatar

  • Endpoint: POST /api/upload-avatar
  • Body: FormData with file field
  • Response: { url: string }
  • Max Size: 5MB
  • Formats: JPG, PNG, GIF

Troubleshooting

Profile not loading?

  • Refresh the page to reload profile data
  • Check your internet connection
  • Try logging out and back in

Avatar upload failing?

  • Ensure image is under 5MB
  • Use JPG, PNG, or GIF format
  • Check file isn’t corrupted
  • Try a different image

Name changes not reflecting?

  • Wait a few seconds for database sync
  • Refresh the page
  • Check both first and last name are filled

Can’t update password?

  • Verify new password is at least 6 characters
  • Ensure passwords match exactly
  • Check you’re entering correct current password

Build docs developers (and LLMs) love