Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion web/src/pages/UsersOverviewPage/UsersTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { isPresent } from '../../shared/defguard-ui/utils/isPresent';
import { openModal } from '../../shared/hooks/modalControls/modalsSubjects';
import { ModalName } from '../../shared/hooks/modalControls/modalTypes';
import { useApp } from '../../shared/hooks/useApp';
import { useAuth } from '../../shared/hooks/useAuth';
import {
getGroupsInfoQueryOptions,
getLicenseInfoQueryOptions,
Expand All @@ -55,6 +56,7 @@ export const UsersTable = () => {
const { data: users } = useSuspenseQuery(getUsersOverviewQueryOptions);
const { data: license } = useSuspenseQuery(getLicenseInfoQueryOptions);
const appInfo = useApp((s) => s.appInfo);
const authUsername = useAuth((s) => s.user?.username);
const reservedEmails = useMemo(() => users.map((u) => u.email.toLowerCase()), [users]);
const reservedUsernames = useMemo(() => users.map((u) => u.username), [users]);

Expand Down Expand Up @@ -267,7 +269,7 @@ export const UsersTable = () => {
testId: 'change-password',
onClick: () => {
openModal(ModalName.ChangePassword, {
adminForm: true,
adminForm: rowData.username !== authUsername,
user: rowData,
});
},
Expand Down Expand Up @@ -415,6 +417,7 @@ export const UsersTable = () => {
handleEditGroups,
groups,
appInfo,
authUsername,
],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const ProfileAuthCard = () => {
const securityKeys = useUserProfile((s) => s.security_keys);
const user = useUserProfile((s) => s.user);
const authUsername = useAuth((s) => s.user?.username as string);
const isCurrentUserAdmin = useAuth((s) => s.isAdmin);
const smtpEnabled = useApp((s) => s.appInfo.smtp_enabled);
const devices = useUserProfile((s) => s.devices);
const biometricDevices = useMemo(
Expand Down Expand Up @@ -269,7 +270,7 @@ export const ProfileAuthCard = () => {
// open admin form only if admin and is not editing self
openModal('changePassword', {
user,
adminForm: user.is_admin && user.username !== authUsername,
adminForm: isCurrentUserAdmin && user.username !== authUsername,
});
}}
/>
Expand Down
Loading