link-stack/apps/leafcutter/middleware.ts

27 lines
450 B
TypeScript
Raw Permalink Normal View History

2024-03-20 17:51:21 +01:00
2023-08-25 07:11:33 +00:00
import { withAuth } from "next-auth/middleware";
2023-06-28 09:09:45 +00:00
2023-05-25 12:37:14 +00:00
export default withAuth(
{
pages: {
signIn: `/login`,
},
callbacks: {
2024-03-20 17:51:21 +01:00
authorized: ({ token }) => {
// check for existence in opensearch user list
2023-08-25 07:11:33 +00:00
if (token?.email) {
2023-06-28 09:09:45 +00:00
return true;
}
return false;
2023-05-25 12:37:14 +00:00
},
}
}
);
2023-08-25 07:11:33 +00:00
export const config = {
matcher: [
2024-03-20 17:51:21 +01:00
'/((?!api|app|login|_next/static|_next/image|favicon.ico).*)',
2023-08-25 07:11:33 +00:00
],
};