Skip to content

Commit 11a8967

Browse files
chore(auth): Minor UX Improvements (#242)
* chore(join): Correct capitalisation of SMS * chore(email): Add sender name to welcome email * feat(auth): Separate committee and admin roles and add wiki link for committee * chore(ci): Remove old staging branch from pull request workflow
1 parent c349e21 commit 11a8967

File tree

9 files changed

+25
-7
lines changed

9 files changed

+25
-7
lines changed

.github/workflows/ci-dev-pr.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ on:
33
pull_request:
44
branches:
55
- main
6-
- 2025
76

87
jobs:
98
lint-format:

next-auth.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ declare module 'next-auth' {
99
firstName?: string;
1010
lastName?: string;
1111
isCommittee?: boolean;
12+
isAdmin?: boolean;
1213
};
1314
}
1415
}

src/app/(account)/join/steps/StepTwo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default function StepTwo() {
7474
label="Phone Number (optional)"
7575
control={form.control}
7676
name="phoneNumber"
77-
longLabel="Providing your phone number allows you to receive sms updates about internships, graduate opportunities, and club notifications."
77+
longLabel="Providing your phone number allows you to receive SMS updates about internships, graduate opportunities, and club notifications."
7878
/>
7979
<ControlledField
8080
label="Are you a university student?"

src/app/admin/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export type Member = {
5959

6060
export default async function AdminPage({ searchParams }: { searchParams?: { page?: string } }) {
6161
const session = await auth();
62-
if (!session?.user?.isCommittee) {
62+
if (!session?.user?.isAdmin) {
6363
return notFound();
6464
}
6565

src/app/api/payment/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export async function PUT(request: Request) {
9999
});
100100

101101
const session = await auth();
102-
if (!session?.user?.isCommittee) {
102+
if (!session?.user?.isAdmin) {
103103
return new Response(null, { status: 401 });
104104
}
105105

src/auth.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ interface ExtendedSession extends Session {
2222
firstName?: string;
2323
lastName?: string;
2424
isCommittee?: boolean;
25+
isAdmin?: boolean;
2526
};
2627
}
2728

@@ -32,9 +33,12 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
3233
async jwt({ token, user, account, profile }) {
3334
if (account?.access_token) {
3435
const decodedToken = decodeJwt<KeycloakToken>(account.access_token);
35-
if (decodedToken?.realm_access?.roles?.includes('restricted-access')) {
36+
if (decodedToken?.realm_access?.roles?.includes('committee')) {
3637
token.isCommittee = true;
3738
}
39+
if (decodedToken?.realm_access?.roles?.includes('restricted-access')) {
40+
token.isAdmin = true;
41+
}
3842
}
3943
if (user) {
4044
token.email = user.email;
@@ -61,6 +65,9 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
6165
(session.user as ExtendedSession['user']).isCommittee = token.isCommittee as
6266
| boolean
6367
| undefined;
68+
(session.user as ExtendedSession['user']).isAdmin = token.isAdmin as
69+
| boolean
70+
| undefined;
6471
}
6572
return session;
6673
},

src/components/Header/components/Links.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ export function MenuLinks({ data, onClick }: { data: HeaderData; onClick?: () =>
2222
Settings
2323
</Link>
2424
)}
25+
{data.isCommittee && (
26+
<Link
27+
href="https://wiki.csclub.org.au"
28+
target="_blank"
29+
className="block hover:underline"
30+
onClick={onClick}
31+
>
32+
Wiki
33+
</Link>
34+
)}
2535
{data.isAdmin && (
2636
<Link href="/admin" className="block hover:underline" onClick={onClick}>
2737
Admin Panel

src/components/Header/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ const getHeaderData = async () => {
3838
return {
3939
isSignedIn: true as const,
4040
avatar: avatar,
41-
isAdmin: session?.user
41+
isCommittee: session?.user
4242
? ((session.user.isCommittee as boolean | undefined) ?? false)
4343
: false,
44+
isAdmin: session?.user ? ((session.user.isAdmin as boolean | undefined) ?? false) : false,
4445
nextStep,
4546
isMember: nextStep === null,
4647
};

src/server/send-welcome-email.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const sendWelcomeEmail = async (
2323
const emailHtml = await render(React.createElement(Email, { firstName }));
2424

2525
const options = {
26-
from: env.SMTP_EMAIL_ADDRESS,
26+
from: `CS Club <${env.SMTP_EMAIL_ADDRESS}>`,
2727
to: recipientEmail,
2828
subject: 'Welcome to the CS Club!',
2929
html: emailHtml,

0 commit comments

Comments
 (0)