This is an automated email from the ASF dual-hosted git repository.
DImuthuUpe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata.git
The following commit(s) were added to refs/heads/master by this push:
new 5dcf8b0a7a Fixing the admin only user list capability to permission
level
5dcf8b0a7a is described below
commit 5dcf8b0a7ab495375cad37d36a63bfbfe5a6c904
Author: DImuthuUpe <[email protected]>
AuthorDate: Thu Nov 12 07:04:47 2026 -0500
Fixing the admin only user list capability to permission level
---
dashboard/src/app/groups/page.tsx | 7 ++++---
dashboard/src/app/users/page.tsx | 9 +++++----
dashboard/src/components/ShareDialog.tsx | 9 +++++----
3 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/dashboard/src/app/groups/page.tsx
b/dashboard/src/app/groups/page.tsx
index ad0b5cd074..4e20a22792 100644
--- a/dashboard/src/app/groups/page.tsx
+++ b/dashboard/src/app/groups/page.tsx
@@ -151,13 +151,14 @@ function GroupDetail({
onClose: () => void;
onChanged: (g: Group | null) => void;
}) {
- const { me, isAdmin } = useSession();
+ const { me, isAdmin, can } = useSession();
+ const canListUsers = can("user:list");
const base = groupPath(group);
const members = useResource(() => api.get<GroupMember[]>(`${base}/members`),
[base]);
// Admins can pick from the user list; everyone else types a user id.
const users = useResource(
- () => (isAdmin ? api.get<UserAccount[]>("/api/v1/users") :
Promise.resolve([] as UserAccount[])),
- [isAdmin],
+ () => (canListUsers ? api.get<UserAccount[]>("/api/v1/users") :
Promise.resolve([] as UserAccount[])),
+ [canListUsers],
);
const [rowError, setRowError] = useState<string | null>(null);
diff --git a/dashboard/src/app/users/page.tsx b/dashboard/src/app/users/page.tsx
index 83b8fefe85..8dc3d0c848 100644
--- a/dashboard/src/app/users/page.tsx
+++ b/dashboard/src/app/users/page.tsx
@@ -16,10 +16,11 @@ const fullName = (u: UserAccount) => [u.firstName,
u.lastName].filter(Boolean).j
const isAdminAccount = (u: UserAccount) => u.roles.includes("ADMIN") ||
u.roles.includes("SUPER_ADMIN");
export default function UsersPage() {
- const { me, isAdmin } = useSession();
+ const { me, can } = useSession();
+ const canListUsers = can("user:list");
const users = useResource(
- () => (isAdmin ? api.get<UserAccount[]>("/api/v1/users") :
Promise.resolve([])),
- [isAdmin],
+ () => (canListUsers ? api.get<UserAccount[]>("/api/v1/users") :
Promise.resolve([])),
+ [canListUsers],
);
// Opens on the accounts waiting for a decision, which is why an admin
usually comes here.
const [tab, setTab] = useState<Tab>("SUSPENDED");
@@ -59,7 +60,7 @@ export default function UsersPage() {
}
};
- if (!isAdmin) {
+ if (!canListUsers) {
return (
<div className="stack">
<PageHead title="Users" />
diff --git a/dashboard/src/components/ShareDialog.tsx
b/dashboard/src/components/ShareDialog.tsx
index 72a93f05d2..5bac26d3ad 100644
--- a/dashboard/src/components/ShareDialog.tsx
+++ b/dashboard/src/components/ShareDialog.tsx
@@ -27,15 +27,16 @@ export function ShareDialog({
permissionHelp: Record<Permission, string>;
onClose: () => void;
}) {
- const { isAdmin } = useSession();
+ const { can } = useSession();
+ const canListUsers = can("user:list");
const sharesPath = `${resourcePath}/shares`;
const shares = useResource(() => api.get<ResourceShare[]>(sharesPath),
[sharesPath]);
// Groups the caller owns or belongs to are the ones they can name. Everyone
may list
- // their own; the full user list is admin-only, so others type a user id.
+ // their own; the full user list needs user:list, so others type a user id.
const groups = useResource(() => api.get<Group[]>("/api/v1/groups/me"));
const users = useResource(
- () => (isAdmin ? api.get<UserAccount[]>("/api/v1/users") :
Promise.resolve([] as UserAccount[])),
- [isAdmin],
+ () => (canListUsers ? api.get<UserAccount[]>("/api/v1/users") :
Promise.resolve([] as UserAccount[])),
+ [canListUsers],
);
const [principalType, setPrincipalType] = useState<PrincipalType>("USER");