Skip to content

Commit

Permalink
Hide anonymous users on the group page
Browse files Browse the repository at this point in the history
Except for the owner and admins, they see an Anonymous badge instead
  • Loading branch information
tomitheninja committed Aug 25, 2021
1 parent 9714ccb commit 3fae575
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/components/groups/group.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
})

Expand Down
32 changes: 20 additions & 12 deletions views/group/show.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 3fae575

Please sign in to comment.