Skip to content
Open
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
3 changes: 2 additions & 1 deletion messages/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,8 @@
"deleteApplication": "Delete application",
"deleteApplicationTitle": "Are you sure you want to delete this application?",
"deleteApplicationDescription": "This action cannot be undone.",
"applicationDeleted": "Application deleted successfully"
"applicationDeleted": "Application deleted successfully",
"unauthorized": "Unauthorized to view applications"
},
"api": {
"fetchGroupFailed": "Failed to retrieve group",
Expand Down
3 changes: 2 additions & 1 deletion messages/nb-NO.json
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,8 @@
"deleteApplication": "Slett søknad",
"deleteApplicationTitle": "Er du sikker på at du vil slette denne søknaden?",
"deleteApplicationDescription": "Denne handlingen kan ikke angres.",
"applicationDeleted": "Søknad slettet"
"applicationDeleted": "Søknad slettet",
"unauthorized": "Du har ikke rettigheter til å se søknader"
},
"api": {
"fetchGroupFailed": "Kunne ikke hente gruppe",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default async function EditGroupPage({
const t = await getTranslations('groups.update');

if (
!user?.groups.some((g) => ['labops', 'leadership', 'admin'].includes(g))
!user?.groups.some((g) => ['labops', 'management', 'admin'].includes(g))
) {
// TODO: Actually return a HTTP 401 Unauthorized reponse whenever `unauthorized.tsx` is stable
return <ErrorPageContent message={t('unauthorized')} />;
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/(default)/about/group/[name]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default async function GroupPage({
</Badge>
)}
{user?.groups.some((g) =>
['labops', 'leadership', 'admin'].includes(g),
['labops', 'management', 'admin'].includes(g),
) && (
<Link
className='-translate-y-1/2 absolute top-1/2 right-0'
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/(default)/about/group/new/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default async function NewGroupPage({
const { about, groups, ui, error } = await getMessages();

if (
!user?.groups.some((g) => ['labops', 'leadership', 'admin'].includes(g))
!user?.groups.some((g) => ['labops', 'management', 'admin'].includes(g))
) {
// TODO: Actually return a HTTP 401 Unauthorized reponse whenever `unauthorized.tsx` is stable
return <ErrorPageContent message={t('new.unauthorized')} />;
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/(default)/about/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default async function AboutPage({
<div className='relative'>
<h2 className='my-4 md:text-center'>{t('activeGroup')}</h2>
{user?.groups.some((g) =>
['labops', 'leadership', 'admin'].includes(g),
['labops', 'management', 'admin'].includes(g),
) && (
<Link
className='-translate-y-1/2 absolute top-1/2 right-0'
Expand Down
11 changes: 10 additions & 1 deletion src/app/[locale]/(default)/applications/view/[appId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
setRequestLocale,
} from 'next-intl/server';
import { DeleteApplicationButton } from '@/components/applications/DeleteApplicationButton';
import { ErrorPageContent } from '@/components/layout/ErrorPageContent';
import { ExternalLink, Link } from '@/components/ui/Link';
import { api } from '@/lib/api/server';

Expand All @@ -31,10 +32,18 @@ export default async function ApplicationPage({
Number.isNaN(processedAppId) ||
!Number.isInteger(processedAppId) ||
processedAppId < 1
)
) {
return notFound();
}

const { user } = await api.auth.state();

const t = await getTranslations('applications.view');

if (!user?.groups.some((group) => ['management', 'admin'].includes(group))) {
return <ErrorPageContent message={t('unauthorized')} />;
}

const tUi = await getTranslations('ui');
const tApply = await getTranslations('applications.apply');
const formatter = await getFormatter();
Expand Down
12 changes: 8 additions & 4 deletions src/app/[locale]/(default)/applications/view/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getTranslations,
setRequestLocale,
} from 'next-intl/server';
import { ErrorPageContent } from '@/components/layout/ErrorPageContent';
import {
Card,
CardContent,
Expand Down Expand Up @@ -34,13 +35,16 @@ export default async function ApplicationsPage({
setRequestLocale(locale as Locale);

const t = await getTranslations('applications.view');
const applications = await api.applications.fetchApplications();
const formatter = await getFormatter();

const { user } = await api.auth.state();

if (!user?.groups.some((group) => ['management', 'admin'].includes(group))) {
return <ErrorPageContent message={t('unauthorized')} />;
}

const applications = await api.applications.fetchApplications();
const formatter = await getFormatter();
const canViewAll =
user?.groups.includes('admin') || user?.groups.includes('leadership');
user?.groups.includes('leadership') || user?.groups.includes('admin');

if (!applications) return notFound();

Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/(default)/events/[eventId]/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default async function EditEventPage({
const { user } = await api.auth.state();

if (
!user?.groups.some((g) => ['labops', 'leadership', 'admin'].includes(g))
!user?.groups.some((g) => ['labops', 'management', 'admin'].includes(g))
) {
// TODO: Actually return a HTTP 401 Unauthorized reponse whenever `unathorized.tsx` is stable
return <ErrorPageContent message={t('edit.unauthorized')} />;
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/(default)/events/[eventId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default async function EventDetailsPage({
const signUpInfo = user ? await api.events.fetchUserSignUp(event.id) : null;

const canEdit = user?.groups.some((group) =>
['labops', 'leadership', 'admin'].includes(group),
['labops', 'management', 'admin'].includes(group),
);

const imageUrl = event.imageId
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/(default)/events/new/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default async function NewEventPage({
const { user } = await api.auth.state();

if (
!user?.groups.some((g) => ['labops', 'leadership', 'admin'].includes(g))
!user?.groups.some((g) => ['labops', 'management', 'admin'].includes(g))
) {
// TODO: Actually return a HTTP 401 Unauthorized reponse whenever `unathorized.tsx` is stable
return <ErrorPageContent message={t('unauthorized')} />;
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/(default)/events/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default async function EventsPage({
<h1 className='my-4 text-center'>{t('title')}</h1>
<div className='absolute right-0 xs:right-5 bottom-0 flex gap-2'>
{user?.groups.some((group) =>
['labops', 'leadership', 'admin'].includes(group),
['labops', 'management', 'admin'].includes(group),
) && (
<Link variant='default' size='icon' href='/events/new'>
<PlusIcon />
Expand Down
1 change: 1 addition & 0 deletions src/app/[locale]/(default)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default async function DefaultLayout({
}: DefaultLayoutProps) {
const { locale } = await params;
setRequestLocale(locale as Locale);

return (
<>
<Header />
Expand Down
4 changes: 1 addition & 3 deletions src/app/[locale]/(default)/management/users/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ export default async function UsersManagementPage({
const tUi = await getTranslations('ui');
const { user } = await api.auth.state();

if (
!user?.groups.some((g) => ['leadership', 'management', 'admin'].includes(g))
) {
if (!user?.groups.some((g) => ['leadership', 'admin'].includes(g))) {
// TODO: Actually return a HTTP 401 Unauthorized reponse whenever `unauthorized.tsx` is stable
return <ErrorPageContent message={t('unauthorized')} />;
}
Expand Down
5 changes: 3 additions & 2 deletions src/app/[locale]/(default)/members/[memberId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ export async function generateMetadata({
!memberId ||
Number.isNaN(processedMemberId) ||
!Number.isInteger(processedMemberId)
)
) {
return;
}

const user = await api.users.fetchMember({
id: processedMemberId,
Expand Down Expand Up @@ -85,7 +86,7 @@ export default async function MemberPage({
const groups = await api.groups.fetchGroups();
const skills = await api.skills.fetchAllSkills();
const canEdit = auth.user?.groups.some((g) =>
['admin', 'management'].includes(g),
['management', 'admin'].includes(g),
);
const { about, members, ui } = await getMessages();

Expand Down
4 changes: 1 addition & 3 deletions src/app/[locale]/(default)/news/[articleId]/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ export default async function EditArticlePage({

if (Number.isNaN(Number(articleId))) return notFound();

if (
!user?.groups.some((g) => ['labops', 'leadership', 'admin'].includes(g))
) {
if (!user || user.groups.length === 0) {
// TODO: Actually return a HTTP 401 Unauthorized reponse whenever `unauthorized.tsx` is stable
return <ErrorPageContent message={t('updateArticlesUnauthorized')} />;
}
Expand Down
4 changes: 1 addition & 3 deletions src/app/[locale]/(default)/news/new/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ export default async function NewArticlePage({
const t = await getTranslations('news');
const { news, ui, error } = await getMessages();

if (
!user?.groups.some((g) => ['labops', 'leadership', 'admin'].includes(g))
) {
if (!user || user.groups.length === 0) {
// TODO: Actually return a HTTP 401 Unauthorized reponse whenever `unauthorized.tsx` is stable
return <ErrorPageContent message={t('newArticlesUnauthorized')} />;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/(default)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export default async function HomePage({
params: Promise<{ locale: string }>;
}) {
const { locale } = await params;

setRequestLocale(locale as Locale);

const t = await getTranslations('home');
const tLayout = await getTranslations('layout');

Expand Down
5 changes: 3 additions & 2 deletions src/app/[locale]/(default)/quotes/[quoteId]/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ export default async function NewQuotePage({
Number.isNaN(processedQuoteId) ||
!Number.isInteger(processedQuoteId) ||
processedQuoteId < 1
)
) {
return notFound();
}

const quote = await api.quotes.fetchQuote(processedQuoteId);

if (!quote) return notFound();

if (
!user?.groups.some((g) => ['labops', 'leadership', 'admin'].includes(g)) &&
!user?.groups.some((g) => ['labops', 'management', 'admin'].includes(g)) &&
quote.saidBy.id !== user?.id &&
quote.heardBy.id !== user?.id
) {
Expand Down
6 changes: 4 additions & 2 deletions src/app/[locale]/(default)/reservations/[toolId]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export async function generateMetadata({
Number.isNaN(processedToolId) ||
!Number.isInteger(processedToolId) ||
processedToolId < 1
)
) {
return;
}

const tool = await api.tools.fetchTool(processedToolId);

Expand Down Expand Up @@ -54,8 +55,9 @@ export default async function ReservationItemLayout({
Number.isNaN(processedToolId) ||
!Number.isInteger(processedToolId) ||
processedToolId < 1
)
) {
return notFound();
}

const tool = await api.tools.fetchTool(processedToolId);

Expand Down
3 changes: 2 additions & 1 deletion src/app/[locale]/(default)/reservations/[toolId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ export default async function ToolCalendarPage({
Number.isNaN(processedToolId) ||
!Number.isInteger(processedToolId) ||
processedToolId < 1
)
) {
return notFound();
}

const tool = await api.tools.fetchTool(processedToolId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default async function EditToolPage({
const t = await getTranslations('reservations.tools.edit');

if (
!user?.groups.some((g) => ['labops', 'leadership', 'admin'].includes(g))
!user?.groups.some((g) => ['labops', 'management', 'admin'].includes(g))
) {
// TODO: Actually return a HTTP 401 Unauthorized reponse whenever `unauthorized.tsx` is stable
return <ErrorPageContent message={t('unauthorized')} />;
Expand All @@ -45,8 +45,9 @@ export default async function EditToolPage({
Number.isNaN(processedToolId) ||
!Number.isInteger(processedToolId) ||
processedToolId < 1
)
) {
return notFound();
}

const tool = await api.tools.fetchTool(processedToolId);

Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/(default)/reservations/tools/new/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default async function NewToolPage({
const t = await getTranslations('reservations.tools.new');

if (
!user?.groups.some((g) => ['labops', 'leadership', 'admin'].includes(g))
!user?.groups.some((g) => ['labops', 'management', 'admin'].includes(g))
) {
// TODO: Actually return a HTTP 401 Unauthorized reponse whenever `unauthorized.tsx` is stable
return <ErrorPageContent message={t('unauthorized')} />;
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/(default)/rules/(main)/new/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default async function NewRulePage({
const { rules, ui, error } = await getMessages();

if (
!user?.groups.some((g) => ['labops', 'leadership', 'admin'].includes(g))
!user?.groups.some((g) => ['labops', 'management', 'admin'].includes(g))
) {
// TODO: Actually return a HTTP 401 Unauthorized reponse whenever `unauthorized.tsx` is stable
return <ErrorPageContent message={t('new.unauthorized')} />;
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/(default)/rules/(main)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default async function RulesPage({
<div className='relative'>
<h1 className='text-center'>{t('title')}</h1>
{user?.groups.some((g) =>
['labops', 'leadership', 'admin'].includes(g),
['labops', 'management', 'admin'].includes(g),
) && (
<Link
className='-translate-y-1/2 absolute top-1/2 right-0'
Expand Down
5 changes: 3 additions & 2 deletions src/app/[locale]/(default)/rules/[subsetId]/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ export default async function EditRulePage({
Number.isNaN(processedSubsetId) ||
!Number.isInteger(processedSubsetId) ||
processedSubsetId < 1
)
) {
return notFound();
}

const { user } = await api.auth.state();
const t = await getTranslations('rules');

if (
!user?.groups.some((g) => ['labops', 'leadership', 'admin'].includes(g))
!user?.groups.some((g) => ['labops', 'management', 'admin'].includes(g))
) {
// TODO: Actually return a HTTP 401 Unauthorized reponse whenever `unauthorized.tsx` is stable
return <ErrorPageContent message={t('update.unauthorized')} />;
Expand Down
8 changes: 5 additions & 3 deletions src/app/[locale]/(default)/rules/[subsetId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ export async function generateMetadata({
Number.isNaN(processedSubsetId) ||
!Number.isInteger(processedSubsetId) ||
processedSubsetId < 1
)
) {
return;
}

const rule = await api.rules.fetchRule(processedSubsetId);

Expand All @@ -43,8 +44,9 @@ export default async function RuleSubsetPage({
Number.isNaN(processedSubsetId) ||
!Number.isInteger(processedSubsetId) ||
processedSubsetId < 1
)
) {
return;
}

const rule = await api.rules.fetchRule(processedSubsetId);

Expand All @@ -67,7 +69,7 @@ export default async function RuleSubsetPage({
<div className='relative'>
<h1 className='text-center'>{rule.localization.name}</h1>
{user?.groups.some((g) =>
['labops', 'leadership', 'admin'].includes(g),
['labops', 'management', 'admin'].includes(g),
) && (
<Link
className='-translate-y-1/2 absolute top-1/2 right-0'
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/(default)/shift-schedule/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default async function ShiftSchedulePage({
const doorStatus = await api.office.fetchDoorStatus();

const canClear = user?.groups.some((group) =>
['admin', 'leadership'].includes(group),
['leadership', 'admin'].includes(group),
);
const clearShiftsButton = <ClearShiftsButton />;

Expand Down
4 changes: 2 additions & 2 deletions src/app/[locale]/(default)/storage/(main)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ export default async function StorageLayout({
children,
}: StorageLayoutProps) {
const { locale } = await params;
const { user } = await api.auth.state();
setRequestLocale(locale as Locale);

const t = await getTranslations('storage');
const tUi = await getTranslations('ui');
const { user } = await api.auth.state();

const categories = await api.storage.fetchItemCategoryNames();
const categoriesWithLabel = categories.map((c) => ({ label: c, value: c }));
const canManageStorage = user?.groups.some((group) =>
['labops', 'leadership', 'admin'].includes(group),
['labops', 'management', 'admin'].includes(group),
);

const filters = [
Expand Down
Loading
Loading