Rollen Chunk 7: Benutzerverwaltung und Sicherung strikt Admin-only
This commit is contained in:
1 parent
71dca44c1d
commit
601cbacea7
1 file changed
+39
@@ -272,3 +272,42 @@ export function decideVacation(
|
||||
body: JSON.stringify({ action }),
|
||||
});
|
||||
}
|
||||
|
||||
export interface ManagedUser {
|
||||
id: string;
|
||||
name: string;
|
||||
email: string;
|
||||
role: "admin" | "teamleiter" | "benutzer";
|
||||
}
|
||||
|
||||
export function listUsers(): Promise<{ users: ManagedUser[] }> {
|
||||
return request("/api/users");
|
||||
}
|
||||
|
||||
export function createUser(input: {
|
||||
name: string;
|
||||
email: string;
|
||||
password: string;
|
||||
role: "admin" | "teamleiter" | "benutzer";
|
||||
}): Promise<{ user: ManagedUser }> {
|
||||
return request("/api/users", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
}
|
||||
|
||||
export function setUserRole(
|
||||
id: string,
|
||||
role: "admin" | "teamleiter" | "benutzer",
|
||||
): Promise<{ user: { id: string; role: string } }> {
|
||||
return request(`/api/users/${encodeURIComponent(id)}`, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify({ role }),
|
||||
});
|
||||
}
|
||||
|
||||
export function deleteUser(id: string): Promise<{ deleted: boolean }> {
|
||||
return request(`/api/users/${encodeURIComponent(id)}`, {
|
||||
method: "DELETE",
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user