feat: add team_lead role to user management and update related functionalities

This commit is contained in:
2025-11-14 08:08:01 +01:00
parent eec0c0a281
commit 23b3c0e9e8
8 changed files with 123 additions and 5 deletions

View File

@@ -312,7 +312,7 @@ export default function initializeDatabase() {
name TEXT NOT NULL,
username TEXT UNIQUE NOT NULL,
password_hash TEXT NOT NULL,
role TEXT CHECK(role IN ('admin', 'project_manager', 'user', 'read_only')) DEFAULT 'user',
role TEXT CHECK(role IN ('admin', 'team_lead', 'project_manager', 'user', 'read_only')) DEFAULT 'user',
created_at TEXT DEFAULT CURRENT_TIMESTAMP,
updated_at TEXT DEFAULT CURRENT_TIMESTAMP,
is_active INTEGER DEFAULT 1,

View File

@@ -3,7 +3,8 @@ import { NextResponse } from "next/server"
// Role hierarchy for permission checking
const ROLE_HIERARCHY = {
'admin': 4,
'admin': 5,
'team_lead': 4,
'project_manager': 3,
'user': 2,
'read_only': 1

View File

@@ -53,7 +53,7 @@ export function getAllUsers() {
// Update user role
export function updateUserRole(userId, role) {
const validRoles = ['admin', 'project_manager', 'user', 'read_only']
const validRoles = ['admin', 'team_lead', 'project_manager', 'user', 'read_only']
if (!validRoles.includes(role)) {
throw new Error("Invalid role")
}
@@ -159,7 +159,7 @@ export async function updateUser(userId, updates) {
}
if (updates.role !== undefined) {
const validRoles = ['admin', 'project_manager', 'user', 'read_only'];
const validRoles = ['admin', 'team_lead', 'project_manager', 'user', 'read_only'];
if (!validRoles.includes(updates.role)) {
throw new Error("Invalid role");
}