diff --git a/apps/envited.ascs.digital/common/guards/guards.ts b/apps/envited.ascs.digital/common/guards/guards.ts index f2e0a428..ea3736c9 100644 --- a/apps/envited.ascs.digital/common/guards/guards.ts +++ b/apps/envited.ascs.digital/common/guards/guards.ts @@ -1,4 +1,4 @@ -import { equals, pathOr, prop, propOr } from 'ramda' +import { equals, path, pathOr, prop, propOr } from 'ramda' import { Role, Session, User } from '../../common/types/types' @@ -13,6 +13,6 @@ export const userIsIssuedByLoggedInUser = (user: User) => (session: Session) => equals(prop('issuerId')(user))(pathOr('', ['user', 'pkh'])(session)) export const isOwnProfile = (user: User) => (profile: { name?: string }) => - equals(prop('name')(user))(propOr('', 'name')(profile)) + equals(path(['user', 'name'])(user))(propOr('', 'name')(profile)) export const isUsersCompanyProfile = isOwnProfile diff --git a/apps/envited.ascs.digital/common/serverActions/profiles/update.ts b/apps/envited.ascs.digital/common/serverActions/profiles/update.ts index 4d0f8a5d..fce01929 100644 --- a/apps/envited.ascs.digital/common/serverActions/profiles/update.ts +++ b/apps/envited.ascs.digital/common/serverActions/profiles/update.ts @@ -39,7 +39,7 @@ export const _update = userId: session.user.id, }) } - + if (!isOwnProfile(user)(profile)) { throw forbiddenError({ resource: 'profiles', diff --git a/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx b/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx index 03ec1221..42c99d5b 100644 --- a/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx +++ b/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx @@ -36,9 +36,11 @@ 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) } } @@ -46,6 +48,7 @@ export const HeroHeader: FC = () => { try { await insertUser(INVALID_USER_CREDENTIAL) } catch (error: any) { + error('Something went wrong') setMessage(error.message) } } @@ -53,7 +56,9 @@ export const HeroHeader: FC = () => { 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) } } diff --git a/apps/envited.ascs.digital/modules/Users/Users.tsx b/apps/envited.ascs.digital/modules/Users/Users.tsx index dd343e33..572f7e01 100644 --- a/apps/envited.ascs.digital/modules/Users/Users.tsx +++ b/apps/envited.ascs.digital/modules/Users/Users.tsx @@ -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'