chore: 尝试修复GitHub登录

This commit is contained in:
14790897 2024-03-06 22:53:16 +08:00
parent c037ac1db5
commit 17ce170ab3
2 changed files with 29 additions and 23 deletions

View File

@ -1,3 +1,4 @@
"use server";
import { createClient } from "@/utils/supabase/server";
import Link from "next/link";
import { cookies } from "next/headers";
@ -6,7 +7,7 @@ import LoadingIndicator from "@/components/LoadingIndicator"; // 确保路径正
import { insertUserProfile } from "@/utils/supabase/supabaseutils";
import React from "react";
export default async function WelcomeScreen() {
const [isLoading, setIsLoading] = React.useState(true);
// const [isLoading, setIsLoading] = React.useState(true);
const cookieStore = cookies();
const supabase = createClient(cookieStore);
@ -16,13 +17,15 @@ export default async function WelcomeScreen() {
} = await supabase.auth.getUser();
//profiles表 插入用户信息
await insertUserProfile(data, supabase);
setIsLoading(false);
//2秒后跳转到首页
setTimeout(() => {
// setIsLoading(false);
//1秒后跳转到首页
// setTimeout(() => {
redirect("/");
}, 1000);
// }, 1000);
return user ? (
return (
<>
{user ? (
<div className="flex items-center gap-4">
Hey, {user.email}!
<div style={{ margin: "20px", textAlign: "center" }}>
@ -36,8 +39,8 @@ export default async function WelcomeScreen() {
>
Login
</Link>
)}
<LoadingIndicator />
</>
);
{
isLoading ? <LoadingIndicator /> : null;
}
}

View File

@ -34,6 +34,9 @@ export function SignInGitHub() {
const supabase = createClient();
const { data, error } = await supabase.auth.signInWithOAuth({
provider: "github",
options: {
redirectTo: "https://www.paperai.life/welcome",
},
});
if (error) {
console.error("GitHub authentication failed:", error.message);