* wip: improve user preferences * wip: fix translations and add user danger zone * feat: add user delete button to danger zone * fix: test not working * refactor: add access checks for user edit page, improve not found behaviour, change user preference link in avatar menu to correct link * fix: remove invalid bg for container * chore: address pull request feedback
21 lines
329 B
TypeScript
21 lines
329 B
TypeScript
import type { Session } from "@homarr/auth";
|
|
|
|
export const canAccessUserEditPage = (
|
|
session: Session | null,
|
|
userId: string,
|
|
) => {
|
|
if (!session) {
|
|
return false;
|
|
}
|
|
|
|
if (session.user.id === userId) {
|
|
return true;
|
|
}
|
|
|
|
if (session.user.permissions.includes("admin")) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
};
|