From 73d3b5886745b835551347a418016511dab11b69 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 23 Feb 2025 01:59:00 -0600 Subject: [PATCH] feat: add GitHub sign-in option for cloud environment --- apps/dokploy/pages/index.tsx | 124 +++++++++++++++++++++++------------ 1 file changed, 82 insertions(+), 42 deletions(-) diff --git a/apps/dokploy/pages/index.tsx b/apps/dokploy/pages/index.tsx index 4a85952e6..768498e8c 100644 --- a/apps/dokploy/pages/index.tsx +++ b/apps/dokploy/pages/index.tsx @@ -62,6 +62,7 @@ export default function Home({ IS_CLOUD }: Props) { const [twoFactorCode, setTwoFactorCode] = useState(""); const [isBackupCodeModalOpen, setIsBackupCodeModalOpen] = useState(false); const [backupCode, setBackupCode] = useState(""); + const [isGithubLoading, setIsGithubLoading] = useState(false); const loginForm = useForm({ resolver: zodResolver(LoginSchema), @@ -160,6 +161,26 @@ export default function Home({ IS_CLOUD }: Props) { } }; + const handleGithubSignIn = async () => { + setIsGithubLoading(true); + try { + const { error } = await authClient.signIn.social({ + provider: "github", + }); + + if (error) { + toast.error(error.message); + return; + } + } catch (error) { + toast.error("An error occurred while signing in with GitHub", { + description: error instanceof Error ? error.message : "Unknown error", + }); + } finally { + setIsGithubLoading(false); + } + }; + return ( <>
@@ -180,51 +201,70 @@ export default function Home({ IS_CLOUD }: Props) { )} {!isTwoFactor ? ( -
- - ( - - Email - - - - - - )} - /> - ( - - Password - - - - - - )} - /> + <> + {IS_CLOUD && ( - - + )} +
+ + ( + + Email + + + + + + )} + /> + ( + + Password + + + + + + )} + /> + + + + ) : ( <>