changed session limit and scope of protection
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
// export { default } from "next-auth/middleware";
|
||||||
|
|
||||||
|
// export const config = {
|
||||||
|
// matcher: ["/myportal/", "/myportal/:path*"],
|
||||||
|
// };
|
||||||
|
|
||||||
|
// import { withAuth } from 'next-auth/middleware';
|
||||||
|
|
||||||
|
// export default withAuth({
|
||||||
|
// pages: {
|
||||||
|
// signIn: '/login',
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
|
import { withAuth } from "next-auth/middleware";
|
||||||
|
|
||||||
|
export default withAuth({
|
||||||
|
callbacks: {
|
||||||
|
authorized: ({ req }) => {
|
||||||
|
// verify token and return a boolean
|
||||||
|
const sessionToken = req.cookies.get("next-auth.session-token");
|
||||||
|
if (sessionToken) return true;
|
||||||
|
else return false;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const config = {
|
||||||
|
matcher: [
|
||||||
|
"/myportal",
|
||||||
|
"/myportal/:path*",
|
||||||
|
"/newappeal",
|
||||||
|
"/newappeal/:path*",
|
||||||
|
"/account",
|
||||||
|
"/account/:path*",
|
||||||
|
],
|
||||||
|
};
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
// export { default } from "next-auth/middleware";
|
|
||||||
|
|
||||||
// export const config = {
|
|
||||||
// matcher: ["/myportal/", "/myportal/:path*"],
|
|
||||||
// };
|
|
||||||
|
|
||||||
// import { withAuth } from 'next-auth/middleware';
|
|
||||||
|
|
||||||
// export default withAuth({
|
|
||||||
// pages: {
|
|
||||||
// signIn: '/login',
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
@@ -202,10 +202,13 @@ const authOptions = (locale, req, res) => {
|
|||||||
adapter: PrismaAdapter(prisma),
|
adapter: PrismaAdapter(prisma),
|
||||||
secret: process.env.NEXTAUTH_SECRET,
|
secret: process.env.NEXTAUTH_SECRET,
|
||||||
session: {
|
session: {
|
||||||
|
strategy: "database",
|
||||||
jwt: true,
|
jwt: true,
|
||||||
pages: {},
|
pages: {},
|
||||||
theme: "dark",
|
theme: "dark",
|
||||||
debug: true,
|
debug: true,
|
||||||
|
maxAge: 30 * 60,
|
||||||
|
updateAge: 5 * 60, // 24 hours
|
||||||
},
|
},
|
||||||
cookies: {
|
cookies: {
|
||||||
callbackUrl: {
|
callbackUrl: {
|
||||||
@@ -227,7 +230,7 @@ const authOptions = (locale, req, res) => {
|
|||||||
},
|
},
|
||||||
callbacks: {
|
callbacks: {
|
||||||
session: async (session, user) => {
|
session: async (session, user) => {
|
||||||
//console.log(user);
|
console.log("callback in auth", session, user);
|
||||||
return Promise.resolve(session);
|
return Promise.resolve(session);
|
||||||
},
|
},
|
||||||
// redirect({ url, baseUrl }) {
|
// redirect({ url, baseUrl }) {
|
||||||
|
|||||||
Reference in New Issue
Block a user