From 3fae5755f710ae80707e82df19ef11015127584a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=BCdi=20Tam=C3=A1s?= Date: Wed, 30 Jun 2021 20:26:09 +0200 Subject: [PATCH] Hide anonymous users on the group page Except for the owner and admins, they see an Anonymous badge instead --- src/components/groups/group.routes.ts | 5 +++-- views/group/show.pug | 32 +++++++++++++++++---------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/components/groups/group.routes.ts b/src/components/groups/group.routes.ts index 757c9021..c0681e4b 100644 --- a/src/components/groups/group.routes.ts +++ b/src/components/groups/group.routes.ts @@ -68,10 +68,11 @@ router.get('/:id', getGroup, (req, res) => { const joined = req.group.users.some(u => u.id === (req.user as User).id) - const isOwner = req.group.ownerId === (req.user as User).id + const userId = (req.user as User).id + const isOwner = req.group.ownerId === userId const isAdmin = (req.user as User).role == RoleType.ADMIN res.render('group/show', { - group: req.group, joined, isOwner, format, DATE_FORMAT, isAdmin + group: req.group, joined, isOwner, format, DATE_FORMAT, isAdmin, userId }) }) diff --git a/views/group/show.pug b/views/group/show.pug index 8668b222..7af07cce 100644 --- a/views/group/show.pug +++ b/views/group/show.pug @@ -107,7 +107,7 @@ block content svg(xmlns='http://www.w3.org/2000/svg' alt="Más hely" aria-label="Más hely" fill='none' viewbox='0 0 24 24' stroke='currentColor' class='w-6 h-6') path(stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M3.055 11H5a2 2 0 012 2v1a2 2 0 002 2 2 2 0 012 2v2.945M8 3.935V5.5A2.5 2.5 0 0010.5 8h.5a2 2 0 012 2 2 2 0 104 0 2 2 0 012-2h1.064M15 20.488V18a2 2 0 012-2h3.064M21 12a9 9 0 11-18 0 9 9 0 0118 0z') span(class='text-lg sm:text-xl')= group.place - + if startDate == endDate li(class='flex flex-row items-center space-x-2') //- Heroicon name: calendar @@ -155,17 +155,25 @@ block content h2(class='mb-3 text-3xl uppercase') Résztvevők div(class='flex flex-col items-start space-y-2 text-xl') each user in group.users - div(class='w-full flex flex-row justify-between items-center ml-6 space-x-2') - a(href=`/users/${user.id}` class='lg:whitespace-no-wrap hover:text-blue-500')= user.name - if user.id === group.ownerId - span(class='px-3 py-1 text-sm text-white bg-purple-600 rounded-full') Szervező - else if isOwner || isAdmin - button(type='button' class='px-3 py-1 text-sm text-white btn btn-primary animate-hover cursor-pointer' onClick=`toggleModal( - '/groups/${group.id}/kick/${user.id}', - 'Biztosan ki akarod rúgni ${user.name}-t?', - 'Biztosan ki akarod rúgni ${user.name}-t? Ezt később nem tudod visszavonni!', - 'Kirúgás', - false)`) Kirúgás + div(class='w-full flex flex-row justify-between items-center ml-6') + div + //- is anon and user has no right to see this entry + if user.isAnon && !(isOwner || isAdmin || user.id === userId) + a(href="#" class='lg:whitespace-no-wrap hover:text-blue-500') Anonymous + else + a(href=`/users/${user.id}` class=`lg:whitespace-no-wrap hover:text-blue-500`)= user.name + div(class='space-x-2') + if user.isAnon && (isOwner || isAdmin || user.id === userId) + span(class='px-3 py-1 text-sm text-white bg-gray-700 rounded-full') Anonymous + if user.id === group.ownerId + span(class='px-3 py-1 text-sm text-white bg-purple-600 rounded-full') Szervező + else if isOwner || isAdmin + button(type='button' class='px-3 py-1 text-sm text-white btn btn-primary animate-hover cursor-pointer' onClick=`toggleModal( + '/groups/${group.id}/kick/${user.id}', + 'Biztosan ki akarod rúgni ${user.name}-t?', + 'Biztosan ki akarod rúgni ${user.name}-t? Ezt később nem tudod visszavonni!', + 'Kirúgás', + false)`) Kirúgás +modalTemplate()