Overview
User management allows superadmins to create users, assign them to schools, and configure their roles and permissions. Athena ERP uses a multi-membership model where users can belong to multiple schools with different roles in each.Permission required:
manage:schools - Only superadmins can create and manage users across all schools.User Architecture
Athena ERP separates user identity from school membership:- Users: Global identity managed by Supabase Auth
- School Memberships: Links between users and schools with assigned roles
- Roles: Define permissions within a specific school context
/home/daytona/workspace/source/athena-api/app/models/user.py
Available Roles
| Role | Code | Description |
|---|---|---|
| Rector | rector | School director with full administrative access |
| Coordinator | coordinator | Manages discipline and academic coordination |
| Secretary | secretary | Handles enrollment and administrative tasks |
| Teacher | teacher | Manages grades, attendance, and activities |
| Student | student | Student access to own data and grades |
| Guardian | acudiente | Parent/guardian access to child’s information |
| Superadmin | superadmin | Platform administrator (not assignable via memberships) |
/home/daytona/workspace/source/athena-api/app/auth/permissions.py:6
The superadmin role is platform-level and cannot be assigned through school memberships. All other roles are school-specific.
Viewing Users
The admin panel displays all users in the system with their school memberships.Review User Information
Each user record shows:
- Email address
- Full name
- Primary school ID
- Assigned roles in primary school
- All school memberships
- Active/inactive status
- Creation and update timestamps
/home/daytona/workspace/source/athena-api/app/routers/admin.py:173
Creating Users
User creation involves both authentication (Supabase) and application-level setup.Verify School Exists
Confirm the target school exists before creating the user. The system validates the school ID during creation.
Prepare User Information
Gather required information:
- Email: User’s email address (unique, used for login)
- Password: Minimum 8 characters
- Full Name: User’s complete name
- School ID: UUID of the school to assign
- Roles: Array of role codes (minimum 1 role)
Supabase Account Creation
The system creates the user in Supabase Auth using the admin client:
- Generates UUID-based user ID
- Sets up authentication credentials
- Stores user metadata
/home/daytona/workspace/source/athena-api/app/routers/admin.py:202Role Validation
Only school-level roles can be assigned during user creation:superadmin through memberships will fail with a validation error.
Source: /home/daytona/workspace/source/athena-api/app/schemas/admin_user.py:10
Updating User Roles
Roles can be modified for existing school memberships or added for new schools.Identify the User
Locate the user by their UUID. User IDs are returned when listing users or creating new ones.
Specify School and Roles
Update the membership with new role assignments:This replaces all existing roles for the specified school.
Multi-School Assignments
To add a user to a second school:- Call the update roles endpoint with the new school’s ID
- The system creates an additional membership
- User can now access both schools with different role sets
Permission System
Roles map to specific permissions that control feature access:Rector Permissions
Coordinator Permissions
Secretary Permissions
Teacher Permissions
/home/daytona/workspace/source/athena-api/app/auth/permissions.py:18
Permission Hierarchy
The system implements wildcard permission matching:read:allgrants all read permissionswrite:allgrants all write permissionsdelete:allgrants all delete permissions
read:all automatically has read:students, read:grades, etc.
Source: /home/daytona/workspace/source/athena-api/app/auth/permissions.py:78
User Status Management
Activating Users
Users are automatically set to active when:- Initially created
- Roles are updated
- Memberships are modified
Deactivating Users
To deactivate a user, update their status in the database:- Set
User.is_active = falsefor platform-wide deactivation - Set
SchoolMembership.is_active = falsefor school-specific deactivation
Security Considerations
Password Requirements
Password Requirements
Passwords must be at least 8 characters. Supabase Auth handles password hashing and security policies.
Email Uniqueness
Email Uniqueness
Email addresses must be unique across the platform. The same email cannot be used for multiple user accounts.
Role Validation
Role Validation
The system validates that only allowed roles are assigned to school memberships. Attempting to assign invalid roles results in a 400 error.
School Context
School Context
Users only see data from schools where they have active memberships. The current school context is determined by the user’s authentication token.
Common Workflows
Creating a School Administrator
Creating a Multi-Role User
Adding User to Second School
Troubleshooting
User Creation Fails
User Creation Fails
Common causes:
- Email already exists in Supabase
- School ID not found
- Invalid role codes
- Password too short
User Cannot Access School
User Cannot Access School
Verify:
- User has an active membership for that school
- Membership
is_activeis true - User
is_activeis true - Roles are correctly assigned
Permission Denied Errors
Permission Denied Errors
Check:
- User’s assigned roles include the required permission
- User is accessing within the correct school context
- Endpoint requires specific permissions (check API docs)
Related Resources
School Management
Create and configure schools
Role Overview
Learn about each role’s capabilities
Permissions System
Deep dive into permission architecture
Authentication
Supabase Auth integration