mirror of
https://github.com/woodchen-ink/Q58Connect.git
synced 2025-07-18 05:51:55 +08:00
feat: Add OAuth state parameter handling in sign-in flow
This commit is contained in:
parent
03107936ad
commit
4fe8f1cb11
@ -48,7 +48,7 @@ export default function LoginPage({ searchParams }: Props) {
|
||||
<span style={{ fontFamily: "Bahamas Bold" }}>Q58 Connect</span>
|
||||
</div>
|
||||
</div>
|
||||
<UserAuthForm />
|
||||
<UserAuthForm oauthState={searchParams.state} />
|
||||
<p className="px-8 text-center text-sm text-muted-foreground">
|
||||
By clicking continue, you agree to our{" "}
|
||||
<Link
|
||||
|
@ -12,10 +12,15 @@ interface DiscourseData {
|
||||
sso_url: string;
|
||||
}
|
||||
|
||||
interface UserAuthFormProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
oauthState?: string;
|
||||
}
|
||||
|
||||
export function UserAuthForm({
|
||||
className,
|
||||
oauthState,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||
}: UserAuthFormProps) {
|
||||
const [isLoading, setIsLoading] = React.useState<boolean>(false);
|
||||
const router = useRouter();
|
||||
const { toast } = useToast();
|
||||
@ -23,6 +28,17 @@ export function UserAuthForm({
|
||||
const signIn = () => {
|
||||
React.startTransition(async () => {
|
||||
try {
|
||||
// 如果有 OAuth 参数,先保存到 cookie
|
||||
if (oauthState) {
|
||||
await fetch("/api/auth/oauth-state", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ state: oauthState }),
|
||||
});
|
||||
}
|
||||
|
||||
const response = await fetch("/api/auth/q58", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user