Permission System
DelightBridge uses a hierarchical permission system with four levels.Permission Levels
- View
- Edit
- Send
- Admin
Read-only access to the workspace:✅ Can:
- View all threads and conversations
- Read email content and message threads
- See AI-generated drafts
- View categories and tags
- Search and filter threads
- Edit drafts or replies
- Send emails
- Change service settings
- Manage team members
Permission Hierarchy
Permissions are cumulative. Higher levels inherit all capabilities from lower levels:types.ts:26-35
The system checks permissions using
hasPermission() utility which compares permission ranks. For example, Admin (rank 3) can perform all actions that require Send (rank 2) or below.Workspace Members
Manage your team members in the Permissions tab of the Settings modal.Adding Team Members
Choose Permission Level
Select the initial permission level from the dropdown (View, Edit, Send, or Admin).
Members are added to the workspace, not individual services. All members can see threads from all services, but permissions apply globally.
Viewing Team Members
The Permissions tab shows all workspace members with:| Column | Description |
|---|---|
| Avatar | First initial of member’s name |
| Name | Full name from Google account |
| Email address (sign-in identifier) | |
| Login Status | ”아직 로그인 안함” (Not yet logged in) if they haven’t accessed the workspace |
| Permission | Current permission level with color coding |
| Actions | Change permission or remove member |
Changing Permissions
Removing Members
- Click the trash icon next to the member’s name
- Confirm the removal
- The member loses access immediately
- Their email is removed from the workspace member list
src/app/api/members/[email]/route.ts
Admin Configuration
Certain actions in DelightBridge require Admin permission.Admin-Only Features
Connect Gmail
Only Admins can connect new Gmail accounts to services via OAuth.Error message for non-Admins:
“Google 계정 연결은 Admin 권한이 필요합니다.”
Service Management
Create, edit, and delete services. Non-Admins can view but not modify service settings.
Documents & Signatures
Edit reference documents and email signatures. Other users see read-only views.
Category Management
Create, edit, and delete categories. Non-Admins use existing categories but cannot change them.
Environment-Based Admins
You can designate permanent Admins via environment variable:- Always have Admin permission (cannot be changed via UI)
- Identified by
isAdminByEnv: trueflag - Cannot be removed from the workspace
- Useful for system administrators and founders
src/lib/admin-emails.ts
Collaboration Workflows
Here are common team workflows enabled by DelightBridge’s permission system.Two-Tier Review Process
Agent Drafts Response
Team member with Edit permission:
- Reviews incoming thread
- Reads AI-generated draft
- Uses Talk to Draft to refine
- Formats the message appropriately
- Leaves thread in “inbox” status
- Junior agents can practice writing responses without risk
- Supervisors maintain quality control
- AI speeds up initial drafting
- Clear separation of responsibilities
Bulk Send Workflow
Agents Prepare Drafts
Multiple team members with Edit permission work in parallel:
- Each takes threads from inbox
- Reviews and refines drafts
- Leaves threads unchecked
- Efficient for high-volume support
- Reduces context switching
- Maintains quality with review step
Distributed Support Team
Shared Inbox
All team members have Send permission and work from the same inbox:
- Agents claim threads by opening them
- Real-time unread status prevents duplicates
- Each agent handles threads independently
- Small teams with flat structure
- Experienced support agents
- Fast-paced environments
User Interface Behavior
The UI adapts based on your permission level.Permission-Based UI Elements
- View Permission
- Edit Permission
- Send Permission
- Admin Permission
UI shows:
- ✅ Sidebar with services (no settings icon)
- ✅ Mail list (read-only)
- ✅ Thread view (read-only)
- ✅ Draft content (read-only, no editor)
- ❌ Draft editor toolbar
- ❌ Send button
- ❌ Talk to Draft panel
- ❌ Settings modal
Permission Check Implementation
Every API route validates permissions server-side:Current User Display
Your current user information appears in the settings sidebar.User Info Card
Shows:- Profile Picture: From Google account (or initials if no picture)
- Name: Full name from Google profile
- Email: Sign-in email address
- Permission Level: Current permission badge
- Confirm you’re logged in with the correct account
- Know your current permission level
- Identify yourself in multi-user sessions
SettingsModal.tsx:180-208
Best Practices
Start with Least Privilege
Start with Least Privilege
Grant the minimum permission needed for each role:
- New hires: Start with View for training period
- Junior agents: Use Edit with supervisor review
- Experienced agents: Grant Send for independence
- Team leads: Provide Admin for full control
Document Your Workflow
Document Your Workflow
Create internal documentation for your team:
- Who has which permission level and why
- Expected workflow (e.g., “Agents draft, supervisors send”)
- How to request permission changes
- Escalation procedures for special cases
Regular Permission Audits
Regular Permission Audits
Review team permissions quarterly:
- Remove members who have left the team
- Adjust permissions based on role changes
- Verify environment-based Admins are still appropriate
- Check for orphaned or unused accounts
Use Multiple Admins
Use Multiple Admins
Don’t rely on a single Admin:
- Designate at least 2-3 Admins
- Include at least one environment-based Admin
- Ensure Admins are in different time zones (for 24/7 teams)
- Document how to access admin controls
Train on Permission Boundaries
Train on Permission Boundaries
Make sure team members understand:
- What they can and cannot do at their permission level
- How to request assistance from higher permission users
- Why certain actions require Admin approval (security, consistency)
- What happens if they try unauthorized actions (error messages, not account suspension)
Authentication Flow
DelightBridge uses NextAuth.js with Google OAuth for authentication.Sign-In Process
User Creation or Lookup
Backend:
- Checks if user exists in
workspace_memberstable - If not found, denies access (must be added by Admin first)
- If found, creates or updates user in
userstable - Loads permission level from
workspace_members
Session Creation
NextAuth creates a session cookie with:
- User ID
- Name
- Picture URL
- Permission level
auth.config.ts and auth.ts
Session Management
Sessions persist across page refreshes:- Session Duration: 30 days by default
- Storage: Encrypted session cookie
- Logout: Click logout in sidebar → redirects to
/login
src/lib/session.ts
Troubleshooting
Member Can't Sign In
Member Can't Sign In
Symptoms: User sees “Unauthorized” or is redirected to login repeatedly.Causes & Solutions:
- Not added to workspace
- Admin must add their email in Settings → Permissions first
- Email must exactly match their Google account
- Wrong Google account
- User must sign in with the exact email added to workspace
- Check for typos or aliases
- Permission set to invalid value
- Verify their permission in database is one of: view, edit, send, admin
Can't Send Emails
Can't Send Emails
Symptoms: Send button is grayed out or missing.Causes & Solutions:
- Insufficient permission
- User needs Send or Admin permission
- Admin can change permission in Settings → Permissions
- Draft not ready
- Draft must be generated or manually entered
- Check that draft content is not empty
- Thread already sent
- Threads with status “sent” cannot be sent again
Can't Access Settings
Can't Access Settings
Symptoms: Settings icon is not visible in sidebar.Cause: User does not have Admin permission.Solution: Admin must change user’s permission to Admin in Settings → Permissions.
Changes Not Visible to Other Users
Changes Not Visible to Other Users
Symptoms: User A makes changes but User B doesn’t see them.Causes & Solutions:
- Stale data
- User B needs to refresh the page
- DelightBridge doesn’t use real-time sync (no WebSockets)
- Cache issue
- Hard refresh (Ctrl+Shift+R or Cmd+Shift+R)
- Clear browser cache
- Sync lag
- Run manual incremental sync in Settings → Services
Related Features
Service Management
Learn how Admins configure services and settings
Email Management
Understand the inbox and thread workflows team members use