feat : use guide login only [no ci]
This commit is contained in:
@@ -10,7 +10,6 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { authClient } from "@/lib/auth/client";
|
||||
import { sudlohStartErrorMessage } from "@/lib/auth/sudloh-redirect";
|
||||
import { ProfileImageInput } from "./profile-image-input";
|
||||
|
||||
declare global {
|
||||
@@ -33,18 +32,12 @@ export function AccountForm({
|
||||
nextPath,
|
||||
verified,
|
||||
verificationError,
|
||||
oidcEnabled,
|
||||
oidcOnly,
|
||||
oidcError,
|
||||
}: {
|
||||
mode: "login" | "register";
|
||||
siteKey: string;
|
||||
nextPath: string;
|
||||
verified?: boolean;
|
||||
verificationError?: boolean;
|
||||
oidcEnabled?: boolean;
|
||||
oidcOnly?: boolean;
|
||||
oidcError?: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const register = mode === "register";
|
||||
@@ -59,7 +52,7 @@ export function AccountForm({
|
||||
const formRef = useRef<HTMLFormElement>(null);
|
||||
const container = useRef<HTMLDivElement>(null);
|
||||
const widget = useRef<string | null>(null);
|
||||
const captcha = !oidcOnly && process.env.NODE_ENV !== "development";
|
||||
const captcha = process.env.NODE_ENV !== "development";
|
||||
useEffect(() => () => {
|
||||
if (profilePreview) URL.revokeObjectURL(profilePreview);
|
||||
}, [profilePreview]);
|
||||
@@ -179,44 +172,12 @@ export function AccountForm({
|
||||
} finally { setBusy(false); }
|
||||
}
|
||||
|
||||
async function signInWithSudloh() {
|
||||
if (busy) return;
|
||||
setBusy(true);
|
||||
setError("");
|
||||
try {
|
||||
const errorCallbackURL = `/auth/login?next=${encodeURIComponent(nextPath)}&sudloh=1`;
|
||||
const result = await authClient.signIn.social({
|
||||
provider: "sudloh", callbackURL: nextPath, errorCallbackURL,
|
||||
});
|
||||
if (result.error) {
|
||||
setError(sudlohStartErrorMessage(result.error.status));
|
||||
setBusy(false);
|
||||
}
|
||||
} catch {
|
||||
setError("เริ่มเข้าสู่ระบบด้วย Sudloh ไม่สำเร็จ กรุณาลองอีกครั้ง");
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Card className="w-full max-w-sm">
|
||||
<CardHeader>
|
||||
<CardTitle>{register ? "สมัครสมาชิก" : "เข้าสู่ระบบ"}</CardTitle>
|
||||
{oidcEnabled && <p className="text-sm text-muted-foreground">
|
||||
{oidcOnly ? "ใช้ Sudloh Account แล้วกลับมายัง Buzz Guide หลังเข้าสู่ระบบ" : "ใช้ Sudloh Account หรือบัญชี Buzz Guide ของคุณ"}
|
||||
</p>}
|
||||
</CardHeader>
|
||||
<CardContent className="flex flex-col gap-4">
|
||||
{oidcEnabled && <Button type="button" variant="outline" disabled={busy} onClick={() => void signInWithSudloh()}>
|
||||
ดำเนินการต่อด้วย Sudloh
|
||||
</Button>}
|
||||
{oidcError && <Alert variant="destructive"><AlertDescription>
|
||||
{oidcError === "account_not_linked"
|
||||
? oidcOnly ? "บัญชีนี้ยังไม่เชื่อมต่อกับ Buzz Guide กรุณาติดต่อผู้ดูแลเพื่อยืนยันตัวตน"
|
||||
: "มีบัญชี Buzz Guide ที่ใช้อีเมลนี้แล้ว กรุณาเข้าสู่ระบบด้วยอีเมลและเชื่อมต่อ Sudloh จากหน้าโปรไฟล์"
|
||||
: "เข้าสู่ระบบด้วย Sudloh ไม่สำเร็จ กรุณาลองอีกครั้ง"}
|
||||
</AlertDescription></Alert>}
|
||||
{!oidcOnly && <>
|
||||
{verified && <Alert><AlertDescription>ยืนยันอีเมลแล้ว กรุณาเข้าสู่ระบบ</AlertDescription></Alert>}
|
||||
{verificationError && <Alert variant="destructive"><AlertDescription>ลิงก์ยืนยันไม่ถูกต้องหรือหมดอายุ กรุณาขอลิงก์ใหม่</AlertDescription></Alert>}
|
||||
{notice && <Alert><AlertDescription>{notice}</AlertDescription></Alert>}
|
||||
@@ -318,7 +279,6 @@ export function AccountForm({
|
||||
<AlertDescription>{error}</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
</>}
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user