-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip * wip
- Loading branch information
Showing
28 changed files
with
764 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 0 additions & 56 deletions
56
apps/web/src/app/[locale]/(dashboard)/invite/[invitationId]/page.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { acceptInvitation } from "@/lib/auth/queries"; | ||
import { getSession } from "@/lib/session"; | ||
import { trpc } from "@/trpc/server"; | ||
import { cookies } from "next/headers"; | ||
import { redirect } from "next/navigation"; | ||
|
||
export async function GET( | ||
_: Request, | ||
{ params }: { params: { inviteId: string } }, | ||
) { | ||
try { | ||
const { inviteId } = params; | ||
|
||
// Check if user is logged in | ||
const session = await getSession(); | ||
const cookieStore = await cookies(); | ||
|
||
if (!session?.data) { | ||
// Set invitation cookie before redirecting | ||
cookieStore.set("invitationId", inviteId); | ||
redirect("/login"); | ||
} | ||
|
||
const invite = await acceptInvitation(inviteId); | ||
|
||
if (!invite) { | ||
redirect("/login"); | ||
} | ||
|
||
// Get organization details | ||
const organization = await trpc.organization.getById({ | ||
organizationId: invite.invitation.organizationId, | ||
}); | ||
|
||
// Redirect to organization dashboard if found | ||
if (organization) { | ||
redirect(`/${organization.slug}/default`); | ||
} | ||
|
||
// Fallback redirect to login | ||
redirect("/login"); | ||
} catch (error) { | ||
redirect("/login"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { deleteInvitation } from "@/db/queries/organization"; | ||
import { acceptInvitation } from "@/lib/auth/queries"; | ||
import { cookies } from "next/headers"; | ||
import { NextResponse } from "next/server"; | ||
|
||
export async function GET(request: Request) { | ||
const cookieStore = await cookies(); | ||
const invitationId = cookieStore.get("invitationId")?.value; | ||
|
||
if (!invitationId) { | ||
return NextResponse.redirect(new URL("/login", request.url)); | ||
} | ||
|
||
try { | ||
const invite = await acceptInvitation(invitationId); | ||
|
||
if (!invite) { | ||
return NextResponse.redirect(new URL("/login", request.url)); | ||
} | ||
|
||
// Clear the invitation cookie | ||
cookieStore.delete("invitationId"); | ||
|
||
await deleteInvitation(invitationId); | ||
|
||
// Redirect to organization dashboard if found | ||
if (invite.invitation.organizationId) { | ||
return NextResponse.redirect( | ||
new URL(`/${invite.invitation.organizationId}/default`, request.url), | ||
); | ||
} | ||
|
||
// Fallback redirect to login | ||
return NextResponse.redirect(new URL("/login", request.url)); | ||
} catch { | ||
return NextResponse.redirect(new URL("/login", request.url)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.