added middleware
This commit is contained in:
parent
3ca6693ebb
commit
38a349055e
6 changed files with 936 additions and 6 deletions
16
scheduler_app/app/(routes)/dashboard/page.js
Normal file
16
scheduler_app/app/(routes)/dashboard/page.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
"use client"
|
||||
import { LogoutLink } from '@kinde-oss/kinde-auth-nextjs'
|
||||
import React from 'react'
|
||||
|
||||
const Dashboard = () => {
|
||||
return (
|
||||
<div>
|
||||
This is a dashboard page
|
||||
<LogoutLink>
|
||||
<button className='px-2 py-1 sm:px-4 sm:py-2 bg-[#101010] text-white rounded-full font-semibold hover:opacity-85 duration-300 text-sm sm:text-md'>Logout</button>
|
||||
</LogoutLink>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Dashboard
|
|
@ -1,19 +1,22 @@
|
|||
"use client"
|
||||
import React from 'react'
|
||||
import Hero from './Hero'
|
||||
import { LoginLink } from '@kinde-oss/kinde-auth-nextjs'
|
||||
import { LoginLink, RegisterLink } from '@kinde-oss/kinde-auth-nextjs'
|
||||
|
||||
const Header = () => {
|
||||
return (
|
||||
<div className='w-full h-screen bg-[#F3F3F3] px-5 py-5 sm:py-10 sm:px-10 md:px-20 lg:px-[150px] xl:px-[200px]'>
|
||||
<div className='w-full h-screen justify-center items-center bg-[#F3F3F3] px-5 py-5 sm:py-10 sm:px-10 md:px-20 lg:px-[150px] xl:px-[200px]'>
|
||||
<div className="flex justify-between items-center ">
|
||||
<div>
|
||||
<p className='text-xl uppercase font-semibold'>Schedule.Me</p>
|
||||
</div>
|
||||
<div>
|
||||
<div className='flex gap-2'>
|
||||
<LoginLink>
|
||||
<button className='px-4 py-2 bg-[#101010] text-white rounded-full font-semibold hover:opacity-85 duration-300'>Login</button>
|
||||
<button className='px-2 py-1 sm:px-4 sm:py-2 bg-[#101010] text-white rounded-full font-semibold hover:opacity-85 duration-300 text-sm sm:text-md'>Login</button>
|
||||
</LoginLink>
|
||||
<RegisterLink>
|
||||
<button className='px-2 py-1 sm:px-4 sm:py-2 border border-[#101010] hover:bg-[gray] hover:border-[gray] hover:text-white rounded-full duration-300 text-sm sm:text-md'>Sign Up</button>
|
||||
</RegisterLink>
|
||||
</div>
|
||||
</div>
|
||||
<Hero/>
|
||||
|
|
|
@ -11,7 +11,7 @@ const Hero = () => {
|
|||
<p className='text-lg sm:text-xl font-semibold'>Set your availability and share your link.</p>
|
||||
<p className='text-lg sm:text-xl font-semibold'>Schedule.Me ensures you never get double booked!</p>
|
||||
</div>
|
||||
<div className='mt-20'>
|
||||
{/*<div className='mt-10 sm:mt-20'>
|
||||
<p className='mb-10 text-sm'>Sign up with <span className='font-semibold'>Google</span> and <span className='font-semibold'>Facebook</span></p>
|
||||
<div className='flex flex-col md:flex md:flex-row gap-5 justify-center items-center text-center'>
|
||||
<button className='flex items-center gap-1 mb-0 md:mb-5 px-4 py-2 border bg-[#101010] text-white hover:opacity-90'><Image src='/google.png' width={20} height={20} alt='google' className='w-[15px] h-[15px]'/>Sign up with Google</button>
|
||||
|
@ -19,7 +19,7 @@ const Hero = () => {
|
|||
</div>
|
||||
<hr className='mb-5 mt-5 w-[350px] mx-auto'/>
|
||||
<Link href="" className='text-sm text-[gray] hover:underline transition-all duration-500'>Sign up with your email</Link>
|
||||
</div>
|
||||
</div>*/}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
16
scheduler_app/middleware.ts
Normal file
16
scheduler_app/middleware.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import {getKindeServerSession} from "@kinde-oss/kinde-auth-nextjs/server";
|
||||
import { NextResponse } from 'next/server'
|
||||
|
||||
// This function can be marked `async` if using `await` inside
|
||||
export async function middleware(request) {
|
||||
const {isAuthenticated} = getKindeServerSession();
|
||||
if(!(await isAuthenticated())){
|
||||
return NextResponse.redirect(new URL('/api/auth/login?post_login_redirect_url=/dashboard', request.url))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// See "Matching Paths" below to learn more
|
||||
export const config = {
|
||||
matcher: '/dashboard/:path*',
|
||||
}
|
894
scheduler_app/package-lock.json
generated
894
scheduler_app/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -13,6 +13,7 @@
|
|||
"@radix-ui/react-slot": "^1.0.2",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"clsx": "^2.1.1",
|
||||
"firebase": "^10.11.1",
|
||||
"lucide-react": "^0.373.0",
|
||||
"next": "14.2.3",
|
||||
"react": "^18",
|
||||
|
|
Loading…
Add table
Reference in a new issue