Implemented a simple authentication scheme with Firebase and Iron Session

This commit is contained in:
Tiago Ribeiro
2023-04-12 16:53:36 +01:00
parent cb1a67de23
commit 58bdc745e4
16 changed files with 1371 additions and 33 deletions

View File

@@ -1,4 +1,6 @@
import axios from "axios";
import Link from "next/link";
import {useRouter} from "next/router";
interface Props {
profilePicture: string;
@@ -6,8 +8,16 @@ interface Props {
/* eslint-disable @next/next/no-img-element */
export default function Navbar({profilePicture}: Props) {
const router = useRouter();
const logout = async () => {
axios.post("/api/logout").finally(() => {
router.push("/login");
});
};
return (
<div className="navbar bg-neutral-100 drop-shadow-md text-black">
<div className="navbar bg-neutral-100 drop-shadow-md text-black z-10">
<div className="flex-1">
<Link className="btn btn-ghost normal-case text-xl" href="/">
IELTS GPT
@@ -34,7 +44,7 @@ export default function Navbar({profilePicture}: Props) {
<a>Settings</a>
</li>
<li>
<a>Logout</a>
<a onClick={logout}>Logout</a>
</li>
</ul>
</div>