diff --git a/src/modules/hub-map/client/components/HubMap.tsx b/src/modules/hub-map/client/components/HubMap.tsx
index e13ecc40..f8baf72a 100644
--- a/src/modules/hub-map/client/components/HubMap.tsx
+++ b/src/modules/hub-map/client/components/HubMap.tsx
@@ -26,17 +26,21 @@ import { useUpcoming } from '../queries'
import { PermissionsValidator } from '#client/components/PermissionsValidator'
import Permissions from '#shared/permissions'
-export const HubMap = () => (
-
- <_HubMap />
-
-)
+export const HubMap = () => {
+ const officeId = useStore(stores.officeId)
+ return (
+
+ <_HubMap />
+
+ )
+}
export const _HubMap = () => {
const officeId = useStore(stores.officeId)
diff --git a/src/modules/users/client/components/ProfileCard.tsx b/src/modules/users/client/components/ProfileCard.tsx
index b332383a..804a6844 100644
--- a/src/modules/users/client/components/ProfileCard.tsx
+++ b/src/modules/users/client/components/ProfileCard.tsx
@@ -83,11 +83,11 @@ export const Card = ({
{user.fullName}
-
+
{[user.jobTitle, user.team].filter(Boolean).join(' ยท ')}
-
+
{userRoles.map((x) => (
@@ -96,7 +96,7 @@ export const Card = ({
))}
-
+
<>
{location && (
@@ -151,12 +151,26 @@ export const Card = ({
)}
>
-
+
)
}
+const MyDetailsVsOthersDetails: React.FC<{
+ isMine: boolean
+ children: React.ReactNode
+}> = (props) => {
+ if (props.isMine) {
+ return <>{props.children}>
+ }
+ return (
+
+ {props.children}
+
+ )
+}
+
export const ProfileCard = () => {
const user = useStore(stores.me)
diff --git a/src/modules/users/client/components/PublicProfile.tsx b/src/modules/users/client/components/PublicProfile.tsx
index a8c319fd..064ce96b 100644
--- a/src/modules/users/client/components/PublicProfile.tsx
+++ b/src/modules/users/client/components/PublicProfile.tsx
@@ -27,14 +27,23 @@ const NoData = () => (
)
-export const PublicProfile: React.FC = (props) => (
-
+export const PublicProfile: React.FC = (props) => {
+ const route = useStore(stores.router)
+ const me = useStore(stores.me)
+ const userId = route?.route === 'publicProfile' ? route.params.userId : null
+ const isMine = me?.id === userId
+
+ return isMine ? (
<_PublicProfile {...props} />
-
-)
+ ) : (
+
+ <_PublicProfile {...props} />
+
+ )
+}
const _PublicProfile: React.FC = ({ portals }) => {
const route = useStore(stores.router)
diff --git a/src/modules/users/server/router.ts b/src/modules/users/server/router.ts
index 7df97841..5efd0ab8 100644
--- a/src/modules/users/server/router.ts
+++ b/src/modules/users/server/router.ts
@@ -258,7 +258,9 @@ const userRouter: FastifyPluginCallback = async function (fastify, opts) {
fastify.get(
'/profile/:userId',
async (req: FastifyRequest<{ Params: { userId: string } }>, reply) => {
- req.check(Permissions.ListProfiles)
+ if (req.user.id !== req.params.userId) {
+ req.check(Permissions.ListProfiles)
+ }
const user = await fastify.db.User.findByPkActive(req.params.userId, {
include: {
as: 'tags',
@@ -392,8 +394,14 @@ const userRouter: FastifyPluginCallback = async function (fastify, opts) {
)
fastify.get('/me/tags', async (req, reply) => {
- req.check(Permissions.ManageProfile)
- req.check(Permissions.ListProfiles)
+ if (
+ !req.permissions.hasAnyOf([
+ Permissions.ListProfiles,
+ Permissions.ManageProfile,
+ ])
+ ) {
+ return reply.throw.accessDenied()
+ }
// FIXME: missed types for sequelize lazy loading methods (many-to-many relation)
// @ts-ignore
const tags = (await req.user.getTags()) as Tag[]