Fix more build errors

This commit is contained in:
Darren Clarke 2023-03-15 12:17:43 +00:00
parent 1bdc1e60db
commit 30ce47826f
61 changed files with 1161 additions and 541 deletions

View file

@ -4,7 +4,7 @@ import Google from "next-auth/providers/google";
import GitHub from "next-auth/providers/github";
import GitLab from "next-auth/providers/gitlab";
import Cognito from "next-auth/providers/cognito";
import { loadConfig, IAppConfig } from "config";
import { loadConfig, IAppConfig } from "@digiresilience/metamigo-config";
import { MetamigoAdapter } from "../../../lib/nextauth-adapter";
import { CloudflareAccessProvider } from "../../../lib/cloudflare";
@ -72,12 +72,12 @@ const nextAuthOptions = (config: IAppConfig, req: NextApiRequest) => {
providers,
adapter,
callbacks: {
session: async (session: any, token: any) => {
async session(session: any, token: any) {
// make the user id available in the react client
session.user.id = token.userId;
return session;
},
jwt: async (token: any, user: any) => {
async jwt(token: any, user: any) {
const isSignIn = Boolean(user);
// Add auth_time to token on signin in
if (isSignIn) {

View file

@ -8,7 +8,7 @@ export default createProxyMiddleware({
changeOrigin: true,
pathRewrite: { "^/graphql": "/graphql" },
xfwd: true,
onProxyReq: function (proxyReq, req, _res) {
onProxyReq(proxyReq, req, _res) {
const auth = proxyReq.getHeader("authorization");
if (auth) {
// pass along user provided authorization header
@ -20,8 +20,8 @@ export default createProxyMiddleware({
let token = req.cookies["__Secure-next-auth.session-token"];
if (!token) token = req.cookies["next-auth.session-token"];
//console.log(req.body);
//if (req.body.query) console.log(req.body.query);
// console.log(req.body);
// if (req.body.query) console.log(req.body.query);
if (token) {
proxyReq.setHeader("authorization", `Bearer ${token}`);
proxyReq.removeHeader("cookie");

View file

@ -8,7 +8,7 @@ export default createProxyMiddleware({
changeOrigin: true,
pathRewrite: { "^/api/v1": "/api" },
xfwd: true,
onProxyReq: function (proxyReq, req, res) {
onProxyReq(proxyReq, req) {
const auth = proxyReq.getHeader("authorization");
if (auth) {
// pass along user provided authorization header
@ -17,7 +17,7 @@ export default createProxyMiddleware({
// Else extract the session token from the cookie and pass
// as bearer token to the proxy target
//const token = req.cookies["next-auth.session-token"];
// const token = req.cookies["next-auth.session-token"];
let token = req.cookies["__Secure-next-auth.session-token"];
if (!token) token = req.cookies["next-auth.session-token"];
@ -27,7 +27,6 @@ export default createProxyMiddleware({
} else {
console.error("no token found. proxied request to backend will fail.");
}
return;
},
});