Users
Internal system users who log in and interact with Renewa One. Every user is backed by a contact record for personal information. Users authenticate via Authentication and are authorized via RBAC Authorization .
Source Files
Layer Path Schema backend/src/db/schema.ts (line ~496)Routes backend/src/routes/users.tsAuth Service backend/src/services/auth-service.tsProfile Page frontend/src/pages/Profile.tsxProfile Sections frontend/src/pages/ProfilePersonalInfoSection.tsx, ProfilePasswordSection.tsx, ProfileTwoFactorSection.tsx, ProfileResponsibilitySection.tsx, ProfileDeleteAccountSection.tsxAdmin frontend/src/pages/admin/UsersAdmin.tsxAuth Store frontend/src/store/auth.ts (Zustand)
Database Tables
Table Purpose usersMain entity — email, type, role, auth fields, contact link sessionsJWT session tokens with rotation and expiry user_skillsM2M linking users to skills with levels user_departmentsM2M linking users to Departments (with isPrimary flag)
Key Fields
Field Type Notes emailvarchar(255) Login email (unique, required) passwordHashtext Argon2id hash via Bun.password.hash() userTypeenum internal or externalinternalRoleenum admin or employee (only for internal users)contactIduuid FK Mandatory link to Contacts for personal info avatarUrlvarchar Profile picture URL languagevarchar(2) UI language preference (de/en) isActiveboolean Account active flag entraIdvarchar Microsoft Entra ID for SSO authProviderenum local or Entra IDtwoFactorSecrettext TOTP secret (encrypted) twoFactorEnabledboolean Whether 2FA is active
User Types
Type Internal Role Description internaladminFull system access, user management internalemployeeStandard internal user external— Craftsmen, partners, external collaborators
Relationships
User *──1 Contact (personal info source of truth)
User *──* Departments (via user_departments)
User *──* Skills (via user_skills)
User 1──* Sessions
User 1──* Buildings (creator)
User 1──* Projects (creator)
Authentication Flow
Login with email/password (argon2id verification via Bun.password)
Optional 2FA via TOTP (twoFactorSecret + authenticator app)
JWT access token + refresh token stored in sessions table
Session rotation with previous-token grace period
SSO option via Microsoft Entra ID (authProvider: 'entra')
See Authentication for full details.
Frontend State
Zustand store at frontend/src/store/auth.ts manages current user, token, and auth state
Profile page with five sections: personal info, password, 2FA, responsibility areas, account deletion
Admin panel at UsersAdmin.tsx for user management (restricted to admins and team leads)
Features
Hybrid RBAC — user type + internal role + per-resource roles (RBAC Authorization )
2FA support — TOTP-based two-factor authentication
Department membership — users belong to Departments with primary department flag
Skill tracking — user competencies via skills and levels
Session management — JWT with refresh rotation and grace periods
Related Pages
Authentication | RBAC Authorization | Contacts | Departments | Admin Dashboard | Database Architecture | Service Layer Pattern