Build and type fixes
This commit is contained in:
parent
d5bd58ac3e
commit
656f3fbe71
64 changed files with 1878 additions and 1501 deletions
30
apps/link/middleware.ts
Normal file
30
apps/link/middleware.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { withAuth } from "next-auth/middleware";
|
||||
|
||||
export default withAuth(
|
||||
() => { },
|
||||
{
|
||||
pages: {
|
||||
signIn: `/login`,
|
||||
},
|
||||
callbacks: {
|
||||
authorized: ({ token, req }) => {
|
||||
const {
|
||||
url,
|
||||
headers,
|
||||
} = req;
|
||||
|
||||
// check login page
|
||||
const parsedURL = new URL(url);
|
||||
if (parsedURL.pathname.startsWith('/login')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// check session auth
|
||||
const authorizedDomains = ["redaranj.com", "digiresilience.org"];
|
||||
const userDomain = token?.email?.toLowerCase().split("@").pop() ?? "unauthorized.net";
|
||||
|
||||
return false;
|
||||
},
|
||||
}
|
||||
}
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue