diff --git a/src/components/CurrentUserProvider.js b/src/components/CurrentUserProvider.js
index b3a2f4e4..673e30b5 100644
--- a/src/components/CurrentUserProvider.js
+++ b/src/components/CurrentUserProvider.js
@@ -16,7 +16,7 @@ const query = {
'surname',
'firstName',
'authorities',
- 'userCredentials[userRoles[id]]',
+ 'userRoles[id]',
'userGroups[id]',
'organisationUnits[id,path,displayName,children::isNotEmpty]',
'dataViewOrganisationUnits[id,path,displayName,children::isNotEmpty]',
@@ -107,7 +107,7 @@ const CurrentUserProvider = ({ children }) => {
firstName: data.me.firstName,
authorities: data.me.authorities,
userGroupIds: data.me.userGroups.map(({ id }) => id),
- userRoleIds: data.me.userCredentials.userRoles.map(({ id }) => id),
+ userRoleIds: data.me.userRoles.map(({ id }) => id),
organisationUnits: data.me.organisationUnits ?? [],
dataViewOrganisationUnits: data.me.dataViewOrganisationUnits ?? [],
teiSearchOrganisationUnits: data.me.teiSearchOrganisationUnits ?? [],
diff --git a/src/components/UserForm/AnalyticsDimensionRestrictionsSection.js b/src/components/UserForm/AnalyticsDimensionRestrictionsSection.js
index 55392c16..1d7e7ddb 100644
--- a/src/components/UserForm/AnalyticsDimensionRestrictionsSection.js
+++ b/src/components/UserForm/AnalyticsDimensionRestrictionsSection.js
@@ -15,8 +15,8 @@ const AnalyticsDimensionsRestrictionsSection = React.memo(
user
? []
.concat(
- user.userCredentials.cogsDimensionConstraints,
- user.userCredentials.catDimensionConstraints
+ user.cogsDimensionConstraints,
+ user.catDimensionConstraints
)
.map(({ id }) => id)
: []
diff --git a/src/components/UserForm/BasicInformationSection.js b/src/components/UserForm/BasicInformationSection.js
index bb5fa1e1..cf6c971f 100644
--- a/src/components/UserForm/BasicInformationSection.js
+++ b/src/components/UserForm/BasicInformationSection.js
@@ -56,7 +56,7 @@ const BasicInformationSection = React.memo(
required={inviteUser !== INVITE_USER}
name="username"
label={i18n.t('Username')}
- initialValue={user?.userCredentials.username}
+ initialValue={user?.username}
disabled={!!user}
autoComplete="new-password"
validate={validateUserName}
@@ -117,7 +117,7 @@ const BasicInformationSection = React.memo(
diff --git a/src/components/UserForm/RolesSection.js b/src/components/UserForm/RolesSection.js
index d906d80a..75e0dd69 100644
--- a/src/components/UserForm/RolesSection.js
+++ b/src/components/UserForm/RolesSection.js
@@ -18,9 +18,7 @@ const RolesSection = React.memo(
leftHeader={i18n.t('Available user roles')}
rightHeader={i18n.t('User roles this user is assigned')}
options={userRoleOptions}
- initialValue={
- user?.userCredentials?.userRoles?.map(({ id }) => id) || []
- }
+ initialValue={user?.userRoles?.map(({ id }) => id) || []}
validate={hasSelectionValidator}
/>
)
diff --git a/src/components/UserForm/UserForm.js b/src/components/UserForm/UserForm.js
index e5fd7cf1..df4a7a44 100644
--- a/src/components/UserForm/UserForm.js
+++ b/src/components/UserForm/UserForm.js
@@ -244,45 +244,43 @@ UserForm.propTypes = {
user: PropTypes.shape({
attributeValues: PropTypes.arrayOf(PropTypes.object.isRequired)
.isRequired,
+ catDimensionConstraints: PropTypes.arrayOf(
+ PropTypes.shape({
+ id: PropTypes.string.isRequired,
+ }).isRequired
+ ).isRequired,
+ cogsDimensionConstraints: PropTypes.arrayOf(
+ PropTypes.shape({
+ id: PropTypes.string.isRequired,
+ }).isRequired
+ ).isRequired,
dataViewOrganisationUnits: OrganisationUnitsPropType.isRequired,
+ disabled: PropTypes.bool.isRequired,
+ externalAuth: PropTypes.bool.isRequired,
firstName: PropTypes.string.isRequired,
id: PropTypes.string.isRequired,
organisationUnits: OrganisationUnitsPropType.isRequired,
surname: PropTypes.string.isRequired,
teiSearchOrganisationUnits: OrganisationUnitsPropType.isRequired,
- userCredentials: PropTypes.shape({
- catDimensionConstraints: PropTypes.arrayOf(
- PropTypes.shape({
- id: PropTypes.string.isRequired,
- }).isRequired
- ).isRequired,
- cogsDimensionConstraints: PropTypes.arrayOf(
- PropTypes.shape({
- id: PropTypes.string.isRequired,
- }).isRequired
- ).isRequired,
- disabled: PropTypes.bool.isRequired,
- externalAuth: PropTypes.bool.isRequired,
- userRoles: PropTypes.arrayOf(
- PropTypes.shape({
- displayName: PropTypes.string.isRequired,
- id: PropTypes.string.isRequired,
- }).isRequired
- ).isRequired,
- username: PropTypes.string.isRequired,
- accountExpiry: PropTypes.string,
- ldapId: PropTypes.string,
- openId: PropTypes.string,
- }).isRequired,
userGroups: PropTypes.arrayOf(
PropTypes.shape({
displayName: PropTypes.string.isRequired,
id: PropTypes.string.isRequired,
}).isRequired
).isRequired,
+ userRoles: PropTypes.arrayOf(
+ PropTypes.shape({
+ displayName: PropTypes.string.isRequired,
+ id: PropTypes.string.isRequired,
+ }).isRequired
+ ).isRequired,
+ username: PropTypes.string.isRequired,
+ accountExpiry: PropTypes.string,
dataViewMaxOrganisationUnitLevel: PropTypes.number,
email: PropTypes.string,
facebookMessenger: PropTypes.string,
+ ldapId: PropTypes.string,
+ openId: PropTypes.string,
phoneNumber: PropTypes.string,
skype: PropTypes.string,
telegram: PropTypes.string,
diff --git a/src/components/UserForm/validators.js b/src/components/UserForm/validators.js
index 7b5c2985..af345975 100644
--- a/src/components/UserForm/validators.js
+++ b/src/components/UserForm/validators.js
@@ -39,7 +39,7 @@ export const useDebouncedUniqueUsernameValidator = ({
export const useUserNameValidator = ({ user, isInviteUser }) => {
const debouncedUniqueUsernameValidator =
useDebouncedUniqueUsernameValidator({
- username: user?.userCredentials.username,
+ username: user?.username,
})
if (user) {
return undefined
diff --git a/src/pages/EditUser.js b/src/pages/EditUser.js
index 8d1edd2b..48e86e25 100644
--- a/src/pages/EditUser.js
+++ b/src/pages/EditUser.js
@@ -20,7 +20,17 @@ const userQuery = {
'dataViewOrganisationUnits[id,displayName,path]',
'teiSearchOrganisationUnits[id,displayName,path]',
'dataViewMaxOrganisationUnitLevel',
- 'userCredentials[id,username,accountExpiry,lastLogin,externalAuth,userRoles[id,displayName],cogsDimensionConstraints[id,displayName,dimensionType],catDimensionConstraints[id,displayName,dimensionType],openId,ldapId,disabled]',
+ 'id',
+ 'username',
+ 'accountExpiry',
+ 'lastLogin',
+ 'externalAuth',
+ 'userRoles[id,displayName]',
+ 'cogsDimensionConstraints[id,displayName,dimensionType]',
+ 'catDimensionConstraints[id,displayName,dimensionType]',
+ 'openId',
+ 'ldapId',
+ 'disabled',
'whatsApp',
'facebookMessenger',
'skype',
@@ -44,7 +54,7 @@ const userSettingsQuery = {
const useUser = (userId) => {
const user = useDataQuery(userQuery, { lazy: true })
- const username = user.data?.user?.userCredentials?.username
+ const username = user.data?.user?.username
const userSettings = useDataQuery(userSettingsQuery, { lazy: true })
useEffect(() => {
diff --git a/src/pages/UserList/ContextMenu/ContextMenu.js b/src/pages/UserList/ContextMenu/ContextMenu.js
index 6021695c..36ac2247 100644
--- a/src/pages/UserList/ContextMenu/ContextMenu.js
+++ b/src/pages/UserList/ContextMenu/ContextMenu.js
@@ -46,11 +46,7 @@ const ContextMenu = ({ user, anchorRef, refetchUsers, onClose }) => {
systemInfo: { emailConfigured },
} = useConfig()
const [CurrentModal, setCurrentModal] = useCurrentModal()
- const {
- access,
- twoFactorEnabled,
- userCredentials: { disabled },
- } = user
+ const { access, twoFactorEnabled, disabled } = user
const canReplicate =
access.update &&
currentUser.authorities.some(
@@ -177,11 +173,9 @@ ContextMenu.propTypes = {
read: PropTypes.bool.isRequired,
update: PropTypes.bool.isRequired,
}).isRequired,
+ disabled: PropTypes.bool.isRequired,
id: PropTypes.string.isRequired,
twoFactorEnabled: PropTypes.bool.isRequired,
- userCredentials: PropTypes.shape({
- disabled: PropTypes.bool.isRequired,
- }).isRequired,
email: PropTypes.string,
}).isRequired,
onClose: PropTypes.func.isRequired,
diff --git a/src/pages/UserList/ContextMenu/Modals/DisableModal.js b/src/pages/UserList/ContextMenu/Modals/DisableModal.js
index 8a0eaa44..1cc01f25 100644
--- a/src/pages/UserList/ContextMenu/Modals/DisableModal.js
+++ b/src/pages/UserList/ContextMenu/Modals/DisableModal.js
@@ -26,7 +26,7 @@ const DisableModal = ({ user, refetchUsers, onClose }) => {
data: [
{
op: 'replace',
- path: '/userCredentials/disabled',
+ path: '/disabled',
value: true,
},
],
diff --git a/src/pages/UserList/ContextMenu/Modals/EnableModal.js b/src/pages/UserList/ContextMenu/Modals/EnableModal.js
index 8233e870..ad66933f 100644
--- a/src/pages/UserList/ContextMenu/Modals/EnableModal.js
+++ b/src/pages/UserList/ContextMenu/Modals/EnableModal.js
@@ -26,7 +26,7 @@ const EnableModal = ({ user, refetchUsers, onClose }) => {
data: [
{
op: 'replace',
- path: '/userCredentials/disabled',
+ path: '/disabled',
value: false,
},
],
diff --git a/src/pages/UserList/UserList.js b/src/pages/UserList/UserList.js
index 57ae85f1..aa6c2435 100644
--- a/src/pages/UserList/UserList.js
+++ b/src/pages/UserList/UserList.js
@@ -35,7 +35,9 @@ const usersQuery = {
'access',
'email',
'twoFactorEnabled',
- 'userCredentials[username,disabled,lastLogin]',
+ 'username',
+ 'disabled',
+ 'lastLogin',
'teiSearchOrganisationUnits[id,path]',
],
order: [
diff --git a/src/pages/UserList/UserTable.js b/src/pages/UserList/UserTable.js
index 3a856dc3..439a6ae6 100644
--- a/src/pages/UserList/UserTable.js
+++ b/src/pages/UserList/UserTable.js
@@ -99,8 +99,14 @@ const UserTable = ({
{users.map((user) => {
- const { id, displayName, access, userCredentials } = user
- const { username, lastLogin, disabled } = userCredentials
+ const {
+ id,
+ displayName,
+ access,
+ username,
+ lastLogin,
+ disabled,
+ } = user
const lastLoginClient = fromServerDate(lastLogin)
const handleClick = () => {
@@ -158,13 +164,11 @@ UserTable.propTypes = {
read: PropTypes.bool.isRequired,
update: PropTypes.bool.isRequired,
}).isRequired,
+ disabled: PropTypes.bool.isRequired,
displayName: PropTypes.string.isRequired,
id: PropTypes.string.isRequired,
- userCredentials: PropTypes.shape({
- disabled: PropTypes.bool.isRequired,
- lastLogin: PropTypes.string,
- username: PropTypes.string,
- }).isRequired,
+ lastLogin: PropTypes.string,
+ username: PropTypes.string,
}).isRequired
),
}
diff --git a/src/pages/UserList/UserTable.test.js b/src/pages/UserList/UserTable.test.js
index 465c3b43..82a32d8e 100644
--- a/src/pages/UserList/UserTable.test.js
+++ b/src/pages/UserList/UserTable.test.js
@@ -84,11 +84,9 @@ describe('', () => {
read: true,
update: true,
},
- userCredentials: {
- username: 'user1',
- lastLogin: '2021-10-15T12:34:56Z',
- disabled: false,
- },
+ username: 'user1',
+ lastLogin: '2021-10-15T12:34:56Z',
+ disabled: false,
},
{
id: 'user-2',
@@ -97,11 +95,9 @@ describe('', () => {
read: true,
update: true,
},
- userCredentials: {
- username: 'user2',
- lastLogin: '2021-09-14T12:34:56Z',
- disabled: true,
- },
+ username: 'user2',
+ lastLogin: '2021-09-14T12:34:56Z',
+ disabled: true,
},
]
@@ -137,8 +133,7 @@ describe('', () => {
).getAllByRole('row')
expect(rows).toHaveLength(users.length)
users.forEach((user, index) => {
- const { displayName, userCredentials } = user
- const { username, lastLogin, disabled } = userCredentials
+ const { displayName, username, lastLogin, disabled } = user
const row = rows[index]
expect(within(row).getAllByRole('cell')).toHaveLength(5)
@@ -180,11 +175,9 @@ describe('', () => {
read: true,
update: true,
},
- userCredentials: {
- username: 'user1',
- lastLogin: '2021-10-15T12:34:56Z',
- disabled: false,
- },
+ username: 'user1',
+ lastLogin: '2021-10-15T12:34:56Z',
+ disabled: false,
},
{
id: 'user-2',
@@ -193,11 +186,9 @@ describe('', () => {
read: true,
update: true,
},
- userCredentials: {
- username: 'user2',
- lastLogin: '2021-09-14T12:34:56Z',
- disabled: true,
- },
+ username: 'user2',
+ lastLogin: '2021-09-14T12:34:56Z',
+ disabled: true,
},
]