Benutzer, Ticketzuweißungen
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user