Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

add google login

Sara Vieiradc3320c244f1
diff --git a/app/auth/login.tsx b/app/auth/login.tsx
index f03e922a89..74375f714b 100644
--- a/app/auth/login.tsx
+++ b/app/auth/login.tsx
@@ -52,7 +52,7 @@ export const Login = ({ errorMessage }: { errorMessage: string }) => {
) : null}
<Flex gap="2" direction="column" align="center">
<Form action="/auth/github" method="post">
- <Button type="submit">
+ <Button type="submit" disabled={!loaderData.githubEnabled}>
<Flex gap="1">
<GithubIcon width="16" />
Login with GitHub
@@ -60,7 +60,7 @@ export const Login = ({ errorMessage }: { errorMessage: string }) => {
</Button>
</Form>
<Form action="/auth/google" method="post">
- <Button type="submit" disabled>
+ <Button type="submit" disabled={!loaderData.googleEnabled}>
<Flex gap="1">
<GoogleIcon width="16" />
Login with Google
diff --git a/app/routes/login/index.tsx b/app/routes/login/index.tsx
index 0b6a9b438e..101d8f860d 100644
--- a/app/routes/login/index.tsx
+++ b/app/routes/login/index.tsx
@@ -15,7 +15,13 @@ export const loader: LoaderFunction = async ({ request }) => {
return redirect(config.dashboardPath);
}
- return { devLogin: process.env.DEV_LOGIN === "true", env };
+ return {
+ devLogin: process.env.DEV_LOGIN === "true",
+ env,
+ githubEnabled: process.env.GH_CLIENT_ID && process.env.GH_CLIENT_SECRET,
+ googleEnabled:
+ process.env.GOOGLE_CLIENT_ID && process.env.GOOGLE_CLIENT_SECRET,
+ };
};
const LoginRoute = () => {
diff --git a/app/services/auth.server.ts b/app/services/auth.server.ts
index fcad2e1beb..f9f541a2aa 100644
--- a/app/services/auth.server.ts
+++ b/app/services/auth.server.ts
@@ -34,8 +34,8 @@ const github = new GitHubStrategy(
const google = new GoogleStrategy(
{
- clientID: "YOUR_CLIENT_ID",
- clientSecret: "YOUR_CLIENT_SECRET",
+ clientID: process.env.GOOGLE_CLIENT_ID as string,
+ clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
callbackURL: `${url}${config.googleCallbackPath}`,
},
async ({ profile, context }) => {
@@ -51,8 +51,9 @@ export const authenticator = new Authenticator<User>(sessionStorage);
if (process.env.GH_CLIENT_ID && process.env.GH_CLIENT_SECRET) {
authenticator.use(github, "github");
}
-authenticator.use(google, "google");
-
+if (process.env.GOOGLE_CLIENT_ID && process.env.GOOGLE_CLIENT_SECRET) {
+ authenticator.use(google, "google");
+}
if (process.env.DEV_LOGIN === "true") {
authenticator.use(
new FormStrategy(async ({ form }) => {