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

Login: route guards #14

Merged
merged 1 commit into from
Nov 3, 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
3 changes: 3 additions & 0 deletions app/login/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default async function LoginPage() {
return <div className="">login</div>;
}
2 changes: 1 addition & 1 deletion components/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function Calendar(props: any) {
console.log(eventInfo);
return (
<Card
className=" fc-event-main-frame w-[100%] rounded-md hover:h-[20vh] hover:transition-all duration-700"
className=" fc-event-main-frame w-[100%] rounded-md hover:h-[20vh] z-0 hover:z-10 hover:transition-all duration-700 "
style={{ backgroundColor: eventInfo.event.extendedProps.daColor }}
>
{/*
Expand Down
6 changes: 2 additions & 4 deletions components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const Navbar = (props: any) => {
</div>
);
// @ts-ignore
/*
if (session.user?.role === "admin") {
adminDashLink = (
<NavbarContent key="admin">
Expand All @@ -85,7 +86,7 @@ export const Navbar = (props: any) => {
</Link>
</NavbarContent>
);
}
}*/
nameButton = session.user?.name;
} else {
authenticated = false;
Expand Down Expand Up @@ -190,9 +191,6 @@ export const Navbar = (props: any) => {
<DropdownMenu aria-label="Static Actions">
<DropdownItem key="myCourses">My Courses</DropdownItem>
<DropdownItem key="loginLink">{loginLink}</DropdownItem>
<DropdownItem key="adminDashLink">
{adminDashLink}
</DropdownItem>
</DropdownMenu>
) : (
<></>
Expand Down
10 changes: 9 additions & 1 deletion lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import { getServerSession } from "next-auth";
// You'll need to import and pass this
// to `NextAuth` in `app/api/auth/[...nextauth]/route.ts`
export const config = {
//Set custom redirect pages
pages: {
signIn: "/login",
//signOut: "/auth/signout",
error: "/error", // Error code passed in query string as ?error=
//verifyRequest: "/auth/verify-request", // (used for check email message)
//newUser: "/auth/new-user", // New users will be directed here on first sign in (leave the property out if not of interest)
},
providers: [
KeycloakProvider({
profile(profile, tokens) {
Expand All @@ -33,7 +41,7 @@ export const config = {
callbacks: {
jwt({ token, user }) {
// @ts-ignore
//if (user) token.role = user.role;
if (user) token.role = user.role;
return token;
},
session({ session, token }) {
Expand Down
9 changes: 9 additions & 0 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { withAuth } from "next-auth/middleware";

export default withAuth({
// Matches the pages config in `[...nextauth]`
pages: {
signIn: "/login",
error: "/error",
},
});
3 changes: 3 additions & 0 deletions styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
transition: all 0.5s ease;
font-family: var(--font-sans);
}
.fc-timegrid-event-harness:hover {
z-index: 10 !important;
}
.fc-day-today {
background-color: inherit !important;
}
Expand Down