Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix admin page access on frontend. #626

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/clubs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,7 @@ def directory(self, request, *args, **kwargs):
@action(detail=False, methods=["get"])
def constitutions(self, request, *args, **kwargs):
"""
A special endpoint for SAC affilaited clubs to check if
A special endpoint for SAC affiliated clubs to check if
they have uploaded a club constitution.
---
operationId: List Club Constitutions
Expand Down
11 changes: 10 additions & 1 deletion frontend/pages/admin/[[...slug]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useRouter } from 'next/router'
import React, { ReactElement } from 'react'
import renderPage from 'renderPage'
import { Badge, ClubFair, Report, Tag } from 'types'
import { doBulkLookup } from 'utils'
import { apiCheckPermission, doBulkLookup } from 'utils'

import { ADMIN_ROUTE, BG_GRADIENT, WHITE } from '~/constants'

Expand All @@ -27,6 +27,15 @@ function AdminPage({
}): ReactElement {
if (!userInfo) {
return <AuthPrompt />
} else if (
!apiCheckPermission(['clubs.approve_club', 'clubs.generate_reports']) &&
!userInfo.is_superuser
) {
return (
<AuthPrompt title="Whoops!" hasLogin={false}>
Admin permissions are required to access this page.
</AuthPrompt>
)
}

const router = useRouter()
Expand Down
Loading