-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Move emails and protect dashboard sub-routes (#8)
- Loading branch information
1 parent
7400d9e
commit 1fdf79f
Showing
20 changed files
with
60 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
import { redirect } from "next/navigation"; | ||
|
||
import getUserSession from "@/utils/getUserSession"; | ||
|
||
export default async function AdminDashboardPage() { | ||
const session = await getUserSession(); | ||
|
||
if (!session || session.user.role !== "admin") { | ||
return redirect("/dashboard"); | ||
} | ||
|
||
return <p>Admin dashboard page</p>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
import { redirect } from "next/navigation"; | ||
|
||
import getUserSession from "@/utils/getUserSession"; | ||
|
||
export default async function ClientDashboardPage() { | ||
const session = await getUserSession(); | ||
|
||
if (!session || session.user.role !== "client") { | ||
return redirect("/dashboard"); | ||
} | ||
|
||
return <p>Client dashboard page</p>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,22 @@ | ||
"use client"; | ||
|
||
import { signOut } from "next-auth/react"; | ||
|
||
export default function ClientComponentTestPage() { | ||
return <p>Client component test page</p>; | ||
const handleSignOut = () => { | ||
signOut() | ||
.then(() => { | ||
alert("Signed out"); | ||
}) | ||
.catch(() => { | ||
alert("Error signing out"); | ||
}); | ||
}; | ||
|
||
return ( | ||
<> | ||
<p>Client component test page</p> | ||
<button onClick={handleSignOut}>Sign out</button> | ||
</> | ||
); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { default } from "next-auth/middleware"; | ||
|
||
export const config = { matcher: ["/dashboard"] }; | ||
export const config = { matcher: ["/dashboard", "/dashboard/:path*"] }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters