Skip to content

add invite system and google oauth provider #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add non auth logic
  • Loading branch information
msukkari committed Feb 10, 2025
commit 37d3a46e33ab908e70baf8a22e91c441ec7b94a8
14 changes: 3 additions & 11 deletions packages/web/src/app/redeem/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { prisma } from "@/prisma";
import { notFound } from 'next/navigation';
import { notFound, redirect } from 'next/navigation';
import { NavigationMenu } from "../components/navigationMenu";
import { auth } from "@/auth";
import { getUser } from "@/data/user";
Expand Down Expand Up @@ -78,15 +78,7 @@ interface RedeemPageProps {
</div>
);
}
} else {
redirect(`/login?callbackUrl=${encodeURIComponent(`/redeem?invite_id=${invite_id}`)}`);
}


return (
<div>
<NavigationMenu />
<h1>Redeem Invite</h1>
<p>Invite ID: {invite.id}</p>
{/* Add more invite details as needed */}
</div>
);
}
6 changes: 6 additions & 0 deletions packages/web/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ const apiMiddleware = (req: NextAuthRequest) => {
}

const defaultMiddleware = (req: NextAuthRequest) => {
// if we're trying to redeem an invite while not authed we continue to the redeem page so
// that we can pipe the invite_id to the login page
if (!req.auth && req.nextUrl.pathname === "/redeem") {
return NextResponse.next();
}

if (!req.auth && req.nextUrl.pathname !== "/login") {
const newUrl = new URL("/login", req.nextUrl.origin);
return NextResponse.redirect(newUrl);
Expand Down