Skip to content

Commit

Permalink
Merge pull request #1399 from bamsalem/permissions-array-validation
Browse files Browse the repository at this point in the history
Add check/validation if permission response is an array, to prevent web ui from crashing
  • Loading branch information
sgratch authored Apr 8, 2021
2 parents d72057b + 35b1314 commit 6f4406d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ovirtapi/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ const VmSessions = {
//
//
const Permissions = {
toInternal ({ permissions }: { permissions: Array<ApiPermissionType> }): Array<PermissionType> {
toInternal ({ permissions = [] }: { permissions: Array<ApiPermissionType> }): Array<PermissionType> {
return permissions.map(permission => ({
name: permission.role.name,
userId: permission.user && permission.user.id,
Expand Down
5 changes: 4 additions & 1 deletion src/sagas/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ export function* delayInMsSteps (count = 20, msMultiplier = 2000) {

export function* fetchPermits ({ entityType, id }) {
const permissions = yield callExternalAction(`get${entityType}Permissions`, Api[`get${entityType}Permissions`], { payload: { id } })
return getUserPermits(Api.permissionsToInternal({ permissions: permissions.permission }))
if (permissions && Array.isArray(permissions.permission)) {
return getUserPermits(Api.permissionsToInternal({ permissions: permissions.permission }))
}
return []
}

export const PermissionsType = {
Expand Down

0 comments on commit 6f4406d

Please sign in to comment.