Skip to content

Commit

Permalink
added redirection page
Browse files Browse the repository at this point in the history
  • Loading branch information
gpalmer27 committed Jan 30, 2025
1 parent e770474 commit ea79496
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
4 changes: 1 addition & 3 deletions apps/auth-proxy/routes/r/[...auth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ export default eventHandler(async (event) =>
],
callbacks: {
async signIn({ user }) {

const email = user?.email;
console.log("email account: ", email)

if (!email?.endsWith("@husky.neu.edu")) {
return false;
return false
}
return true;
},
Expand Down
15 changes: 15 additions & 0 deletions apps/web/src/app/(pages)/(dashboard)/redirection/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";

export default function ErrorPage() {

return (
<div className="min-h-screen flex items-center justify-center">
<div className="text-center">
<h1 className="text-2xl font-bold text-gray-900 mb-4">Authentication Error</h1>
<p className="text-gray-600 mb-4">You must log in with husky.neu.edu</p>
<p className="text-gray-600 mb-4">Click the sign in button to try again</p>
</div>
</div>
);
}

8 changes: 8 additions & 0 deletions packages/auth/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ export const authConfig = {
},
};
},
async signIn({ user }) {
const email = user?.email;

if (!email?.endsWith("@husky.neu.edu")) {
return '/redirection'
}
return true;
},
},
} satisfies NextAuthConfig;

Expand Down
3 changes: 2 additions & 1 deletion packages/auth/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"extends": "@cooper/tsconfig/base.json",
"compilerOptions": {
"jsx": "react",
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
},
"include": ["src", "*.ts"],
"include": ["src", "*.ts", "../../apps/web/error-page.tsx"],
"exclude": ["node_modules"]
}

0 comments on commit ea79496

Please sign in to comment.