Skip to content

Commit

Permalink
Fix profile guard (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
royscheeren authored Feb 2, 2024
2 parents ab40275 + 29de98f commit a77fe7b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ describe('serverActions/profiles/update', () => {
} as any

const user = {
name: 'USER_NAME',
user: {
name: 'USER_NAME',
},
profile: {
name: 'USER_NAME',
},
Expand Down Expand Up @@ -52,7 +54,9 @@ describe('serverActions/profiles/update', () => {
} as any

const user = {
name: 'USER_NAME',
user: {
name: 'USER_NAME',
},
profile: {
name: 'USER_NAME',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const _update =
})
}

if (!isOwnProfile(user)(profile)) {
if (!isOwnProfile(user.user)(profile)) {
throw forbiddenError({
resource: 'profiles',
resourceId: profile.id,
Expand Down
9 changes: 7 additions & 2 deletions apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,29 @@ export const HeroHeader: FC = () => {
const user = await insertUser(USER_CREDENTIAL)
if (user) {
setMessage(`Added ${user.id} as User`)
success('User added')
}
} catch (error) {
console.log(error)
} catch (e) {
error('Something went wrong')
console.log(e)
}
}

const addInvalidUser = async () => {
try {
await insertUser(INVALID_USER_CREDENTIAL)
} catch (error: any) {
error('Something went wrong')
setMessage(error.message)
}
}

const update = async () => {
try {
await updateProfile({ name: 'Testcompany GmbH', description: 'test description' })
success('Profile updated')
} catch (error: any) {
error('Something went wrong')
setMessage(error.message)
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/envited.ascs.digital/modules/Users/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { Card, Heading, Table, TableBody, TableCell, TableHeader, TableRow } from '@envited-marketplace/design-system'
import { TrashIcon } from '@heroicons/react/24/outline'
import { has, map } from 'ramda'
import { map } from 'ramda'
import React, { FC } from 'react'

import { useTranslation } from '../../common/i18n'
Expand Down

0 comments on commit a77fe7b

Please sign in to comment.