Benutzer, Ticketzuweißungen

This commit is contained in:
2026-03-23 03:12:08 +01:00
parent e75a2e5e20
commit 08391cdb6c
29 changed files with 592 additions and 111 deletions

View File

@@ -7,6 +7,16 @@ window.addEventListener('unhandledrejection', (ev) => {
}
});
/** @param {object|null|undefined} user aus /auth/status */
export function canEditCrm(user) {
return user?.canEditCrm === true;
}
/** @param {object|null|undefined} user aus /auth/status */
export function canAdmin(user) {
return user?.canAdmin === true;
}
/**
* @param {{ needsAdmin?: boolean, activeNav?: string }} opts
* @returns {Promise<object|null>} Session-Status oder null bei Redirect
@@ -40,7 +50,7 @@ export async function guard(opts = {}) {
location.href = '/start.html';
return null;
}
if (needsAdmin && st.user?.role !== 'admin') {
if (needsAdmin && !canAdmin(st.user)) {
location.href = '/start.html';
return null;
}