One Calendar is a privacy-first calendar web app built with Next.js. It has modern security features, including e2ee, password-protected sharing, and self-destructing share links ๐Ÿ“… calendar.xyehr.cn
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

restore

authored by

Evan Huang and committed by
GitHub
d265b1d0 81112530

+15 -28
+15 -28
components/auth/login-form.tsx
··· 1 1 "use client"; 2 2 3 - import { Button } from "@/components/ui/button"; 4 3 import { cn } from "@/lib/utils"; 4 + import { Button } from "@/components/ui/button"; 5 5 import { 6 6 Card, 7 7 CardContent, 8 + CardDescription, 8 9 CardHeader, 9 10 CardTitle, 10 11 } from "@/components/ui/card"; ··· 19 20 className, 20 21 ...props 21 22 }: React.ComponentPropsWithoutRef<"div">) { 22 - const { isLoaded, signIn, setActive } = useSignIn(); 23 + const { signIn, setActive } = useSignIn(); 23 24 const [email, setEmail] = useState(""); 24 25 const [password, setPassword] = useState(""); 25 26 const [isLoading, setIsLoading] = useState(false); ··· 73 74 setError(""); 74 75 75 76 try { 76 - if (!isLoaded || !signIn) { 77 - return; 78 - } 79 - 80 77 const result = await signIn.create({ 81 78 identifier: email, 82 79 password, ··· 84 81 85 82 if (result.status === "complete") { 86 83 await setActive({ session: result.createdSessionId }); 87 - router.replace("/app"); 88 - router.refresh(); 89 - window.location.href = "/app"; 84 + router.push("/"); 90 85 } 91 86 } catch (err: any) { 92 87 setError(err.errors?.[0]?.longMessage || "Login failed. Please try again."); ··· 101 96 } 102 97 }; 103 98 104 - const handleOAuthLogin = async (strategy: "oauth_google" | "oauth_microsoft" | "oauth_github") => { 99 + const handleOAuthLogin = (strategy: "oauth_google" | "oauth_microsoft" | "oauth_github") => { 105 100 const siteKey = process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY; 106 101 if (siteKey && !isCaptchaCompleted) { 107 102 setError("Please complete the CAPTCHA verification."); 108 103 return; 109 104 } 110 - if (!isLoaded || !signIn) { 111 - return; 112 - } 113 - 114 - try { 115 - await signIn.authenticateWithRedirect({ 116 - strategy, 117 - redirectUrl: "/sign-in/sso-callback", 118 - redirectUrlComplete: "/app", 119 - }); 120 - } catch (err: any) { 121 - setError(err.errors?.[0]?.longMessage || "OAuth login failed. Please try again."); 122 - } 105 + signIn.authenticateWithRedirect({ 106 + strategy, 107 + redirectUrl: "/sign-in/sso-callback", 108 + redirectUrlComplete: "/", 109 + }); 123 110 }; 124 111 125 112 const siteKey = process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY; ··· 129 116 <Card> 130 117 <CardHeader className="text-center"> 131 118 <CardTitle className="text-xl">Welcome back</CardTitle> 119 + <CardDescription> 120 + Login with your Microsoft, Google or GitHub account 121 + </CardDescription> 132 122 </CardHeader> 133 123 <CardContent> 134 124 <form onSubmit={handleEmailLogin}> ··· 138 128 variant="outline" 139 129 className="w-full" 140 130 type="button" 141 - disabled={!isLoaded} 142 131 onClick={() => handleOAuthLogin("oauth_microsoft")} 143 132 > 144 133 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 23 23" width="20" height="20"> ··· 153 142 variant="outline" 154 143 className="w-full" 155 144 type="button" 156 - disabled={!isLoaded} 157 145 onClick={() => handleOAuthLogin("oauth_google")} 158 146 > 159 147 <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"> ··· 169 157 variant="outline" 170 158 className="w-full" 171 159 type="button" 172 - disabled={!isLoaded} 173 160 onClick={() => handleOAuthLogin("oauth_github")} 174 161 > 175 162 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20"> ··· 237 224 <Button 238 225 type="submit" 239 226 className="w-full bg-[#0066ff] hover:bg-[#0047cc] text-white" 240 - disabled={!isLoaded || (siteKey && (!isCaptchaCompleted || isLoading))} 227 + disabled={siteKey && (!isCaptchaCompleted || isLoading)} 241 228 > 242 - {!isLoaded ? "Loading auth..." : isLoading ? "Signing in..." : "Sign in"} 229 + {isLoading ? "Signing in..." : "Sign in"} 243 230 </Button> 244 231 </div> 245 232 <div className="text-center text-sm">