-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
405 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { getAxiosClient } from "@/client/axios"; | ||
|
||
type VerifyMemberPayload = { | ||
guildId: string; | ||
userId: string; | ||
captchaToken: string; | ||
token: string; | ||
}; | ||
|
||
export const verifyMember = async (payload: VerifyMemberPayload) => { | ||
const res = await getAxiosClient().post( | ||
`/guilds/${encodeURIComponent(payload.guildId)}/members/${encodeURIComponent(payload.userId)}/verify`, | ||
{ | ||
captchaToken: payload.captchaToken, | ||
token: payload.token, | ||
}, | ||
); | ||
|
||
return res.data as { success: boolean; error?: string }; | ||
}; |
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,14 @@ | ||
import HTTPErrorView from "@/components/Errors/HTTPErrorView"; | ||
import { Metadata } from "next"; | ||
|
||
export const metadata: Metadata = { | ||
title: "404 Not Found", | ||
}; | ||
|
||
export default function NotFound() { | ||
return ( | ||
<HTTPErrorView statusCode={404} statusText="Not Found"> | ||
The requested URL was not found on this server. | ||
</HTTPErrorView> | ||
); | ||
} |
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
85 changes: 85 additions & 0 deletions
85
src/app/(main)/verify/guilds/[id]/challenge/onboarding/page.tsx
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,85 @@ | ||
import PageExpired from "@/app/page-expired"; | ||
import GuildVerificationGate from "@/components/GuildVerificationGate/GuildVerificationGate"; | ||
import { Guild } from "@/types/Guild"; | ||
import { ServerComponentProps } from "@/types/ServerComponentProps"; | ||
import axios from "axios"; | ||
import { Metadata } from "next"; | ||
import { notFound } from "next/navigation"; | ||
import { cache } from "react"; | ||
|
||
const getVerificationInfo = cache(async (guildId: string, memberId: string) => { | ||
try { | ||
const info = await axios.get( | ||
`${process.env.NEXT_PUBLIC_API_URL}/guilds/${encodeURIComponent(guildId)}/members/${encodeURIComponent(memberId)}/verify`, | ||
); | ||
return [info.data?.guild as Guild, null] as const; | ||
} catch (error) { | ||
return [null, error] as const; | ||
} | ||
}); | ||
|
||
export async function generateMetadata({ | ||
params, | ||
searchParams, | ||
}: ServerComponentProps): Promise<Metadata> { | ||
const id = params?.id; | ||
const userId = searchParams?.u; | ||
const requestToken = searchParams?.t; | ||
|
||
if (!id || !userId || !requestToken) { | ||
return { | ||
title: "419 Page Expired - SudoBot", | ||
}; | ||
} | ||
|
||
const [guild, error] = id | ||
? await getVerificationInfo(id, userId) | ||
: [null, true]; | ||
|
||
if (!guild || error) { | ||
return { | ||
title: "404 Not Found - SudoBot", | ||
}; | ||
} | ||
|
||
return { | ||
title: "Verify to Continue - SudoBot", | ||
robots: { | ||
index: false, | ||
follow: false, | ||
}, | ||
}; | ||
} | ||
|
||
export default async function VerifyOnboardingPage({ | ||
params, | ||
searchParams, | ||
}: ServerComponentProps) { | ||
const id = params?.id; | ||
const userId = searchParams?.u; | ||
const requestToken = searchParams?.t; | ||
|
||
if (!id || !userId || !requestToken) { | ||
return <PageExpired />; | ||
} | ||
|
||
const [guild, error] = id | ||
? await getVerificationInfo(id, userId) | ||
: [null, true]; | ||
|
||
console.log(guild, error); | ||
|
||
if (!guild || error) { | ||
notFound(); | ||
} | ||
|
||
return ( | ||
<div className="mx-5 flex min-h-[90vh] items-center justify-center"> | ||
<GuildVerificationGate | ||
guild={guild} | ||
userId={userId} | ||
requestToken={requestToken} | ||
/> | ||
</div> | ||
); | ||
} |
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,15 @@ | ||
import HTTPErrorView from "@/components/Errors/HTTPErrorView"; | ||
import { Metadata } from "next"; | ||
|
||
export const metadata: Metadata = { | ||
title: "419 Page Expired", | ||
}; | ||
|
||
export default function PageExpired() { | ||
return ( | ||
<HTTPErrorView statusCode={419} statusText="Page Expired"> | ||
The page has either expired due to inactivity or the request payload | ||
was invalid. | ||
</HTTPErrorView> | ||
); | ||
} |
Oops, something went wrong.