File tree 4 files changed +86
-1
lines changed
4 files changed +86
-1
lines changed Original file line number Diff line number Diff line change 1
1
import type { Metadata } from "next" ;
2
2
import { Inter } from "next/font/google" ;
3
3
import "./globals.css" ;
4
+ import Navbar from "@/components/navigationbar" ;
4
5
5
6
const inter = Inter ( { subsets : [ "latin" ] } ) ;
6
7
@@ -16,7 +17,10 @@ export default function RootLayout({
16
17
} > ) {
17
18
return (
18
19
< html lang = "en" >
19
- < body className = { inter . className } > { children } </ body >
20
+ < body className = { inter . className } >
21
+ < Navbar />
22
+ { children }
23
+ </ body >
20
24
</ html >
21
25
) ;
22
26
}
Original file line number Diff line number Diff line change
1
+ import { cookies } from "next/headers" ;
2
+
3
+ export default function LoginPage ( ) {
4
+ async function handleSubmit ( formData : FormData ) {
5
+ "use server" ;
6
+
7
+ const email = formData . get ( "email" ) ;
8
+ const password = formData . get ( "password" ) ;
9
+
10
+ cookies ( ) . set ( "isLoggedIn" , "1" , { expires : Date . now ( ) + 1000 * 60 * 60 } ) ; //cookie that expires after 1 hour
11
+ }
12
+
13
+ return (
14
+ < form action = { handleSubmit } >
15
+ < input type = "text" name = "email" placeholder = "Email" required />
16
+ < input type = "password" name = "password" placeholder = "Password" required />
17
+ < button type = "submit" > Login</ button >
18
+ </ form >
19
+ ) ;
20
+ }
Original file line number Diff line number Diff line change
1
+ import Link from "next/link" ;
2
+
3
+ export default function Navbar ( ) {
4
+ return (
5
+ < div className = "w-full bg-gray-900" >
6
+ < nav >
7
+ < ul className = "text-2x mx-20 flex h-16 items-center justify-between text-blue-500" >
8
+ < li >
9
+ < Link className = "hover:text-blue-800" href = "/" >
10
+ Home
11
+ </ Link >
12
+ </ li >
13
+ < li >
14
+ < Link className = "hover:text-blue-800" href = "/" >
15
+ Teams
16
+ </ Link >
17
+ </ li >
18
+ < li >
19
+ < Link className = "hover:text-blue-800" href = "/" >
20
+ Standings
21
+ </ Link >
22
+ </ li >
23
+ < li >
24
+ < Link className = "hover:text-blue-800" href = "/" >
25
+ Schedules
26
+ </ Link >
27
+ </ li >
28
+ < li >
29
+ < Link className = "hover:text-blue-800" href = "/" >
30
+ Games
31
+ </ Link >
32
+ </ li >
33
+ < li >
34
+ < Link className = "hover:text-blue-800" href = "/" >
35
+ Volunteers
36
+ </ Link >
37
+ </ li >
38
+ < li >
39
+ < Link className = "hover:text-blue-800" href = "/" >
40
+ History
41
+ </ Link >
42
+ </ li >
43
+ </ ul >
44
+ </ nav >
45
+ </ div >
46
+ ) ;
47
+ }
Original file line number Diff line number Diff line change
1
+ import { NextResponse } from "next/server" ;
2
+ import type { NextRequest } from "next/server" ;
3
+
4
+ export function middleware ( request : NextRequest ) {
5
+ const isLoggedIn = request . cookies . get ( "isLoggedIn" ) ;
6
+
7
+ if ( isLoggedIn && isLoggedIn . value == "0" ) {
8
+ return Response . redirect ( new URL ( "/login" , request . nextUrl ) ) ;
9
+ }
10
+ }
11
+
12
+ export const config = {
13
+ matcher : [ "/logintest" ] ,
14
+ } ;
You can’t perform that action at this time.
0 commit comments