Implement multi tenancy

This commit is contained in:
Sara
2023-10-27 11:26:00 +02:00
committed by Mathieu Virbel
parent 6bd5247bab
commit 4a69bffc9c
37 changed files with 409 additions and 236 deletions

View File

@@ -1,3 +1,13 @@
import { fiefAuth } from "../../app/lib/fief";
import { get } from "@vercel/edge-config";
import { getFiefAuth } from "../../app/lib/fief";
import { NextApiRequest, NextApiResponse } from "next";
export default fiefAuth.currentUser();
export default async (req: NextApiRequest, res: NextApiResponse<any>) => {
const fromUrl = req.headers["referer"] && new URL(req.headers["referer"]);
const fief = fromUrl && (await getFiefAuth(fromUrl));
if (fief) {
return fief.currentUser()(req as any, res as any);
} else {
return res.status(200).json({ userinfo: null, access_token_info: null });
}
};