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

18
src/lib/session.ts Normal file
View File

@@ -0,0 +1,18 @@
// this file is a wrapper with defaults to be used in both API routes and `getServerSideProps` functions
import type {IronSessionOptions} from "iron-session";
import {User} from "@/interfaces/user";
export const sessionOptions: IronSessionOptions = {
password: process.env.SECRET_COOKIE_PASSWORD as string,
cookieName: "eCrop/ielts",
cookieOptions: {
secure: process.env.NODE_ENV === "production",
},
};
// This is where we specify the typings of req.session.*
declare module "iron-session" {
interface IronSessionData {
user?: User | null;
}
}