From ef3ca7ac73c50cd234d253d8336c3b6551d861cc Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal Date: Wed, 4 Oct 2023 19:10:37 +0530 Subject: [PATCH 1/3] chore: remove unnecessary oauth envs --- space/components/accounts/sign-in.tsx | 18 +----------------- turbo.json | 2 -- web/pages/index.tsx | 4 ++-- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/space/components/accounts/sign-in.tsx b/space/components/accounts/sign-in.tsx index c6a151d4423..9e8d067a0b6 100644 --- a/space/components/accounts/sign-in.tsx +++ b/space/components/accounts/sign-in.tsx @@ -63,23 +63,7 @@ export const SignInView = observer(() => { } }; - const handleGitHubSignIn = async (credential: string) => { - try { - if (process.env.NEXT_PUBLIC_GITHUB_ID && credential) { - const socialAuthPayload = { - medium: "github", - credential, - clientId: process.env.NEXT_PUBLIC_GITHUB_ID, - }; - const response = await authenticationService.socialAuth(socialAuthPayload); - onSignInSuccess(response); - } else { - throw Error("Cant find credentials"); - } - } catch (err: any) { - onSignInError(err); - } - }; + const handleGitHubSignIn = async (credential: string) => {}; const handlePasswordSignIn = async (formData: any) => { await authenticationService diff --git a/turbo.json b/turbo.json index 59bbe741f85..5aff42856ed 100644 --- a/turbo.json +++ b/turbo.json @@ -1,8 +1,6 @@ { "$schema": "https://turbo.build/schema.json", "globalEnv": [ - "NEXT_PUBLIC_GITHUB_ID", - "NEXT_PUBLIC_GOOGLE_CLIENTID", "NEXT_PUBLIC_API_BASE_URL", "NEXT_PUBLIC_DEPLOY_URL", "API_BASE_URL", diff --git a/web/pages/index.tsx b/web/pages/index.tsx index ed98d29f638..1696f2fbc6f 100644 --- a/web/pages/index.tsx +++ b/web/pages/index.tsx @@ -85,11 +85,11 @@ const HomePage: NextPage = observer(() => { const handleGitHubSignIn = async (credential: string) => { try { - if (process.env.NEXT_PUBLIC_GITHUB_ID && credential) { + if (data && data.github && credential) { const socialAuthPayload = { medium: "github", credential, - clientId: process.env.NEXT_PUBLIC_GITHUB_ID, + clientId: data.github, }; const response = await authenticationService.socialAuth(socialAuthPayload); if (response && response?.user) { From f4140b32796b7be6be549223f3e87ab2bd8a5635 Mon Sep 17 00:00:00 2001 From: sriramveeraghanta Date: Wed, 4 Oct 2023 20:32:03 +0530 Subject: [PATCH 2/3] merge conflicts resolved --- .../accounts/github-login-button.tsx | 7 +- space/components/accounts/google-login.tsx | 13 ++-- space/components/accounts/sign-in.tsx | 71 +++++++++---------- 3 files changed, 45 insertions(+), 46 deletions(-) diff --git a/space/components/accounts/github-login-button.tsx b/space/components/accounts/github-login-button.tsx index e9b30ab73ed..b1bd586fe76 100644 --- a/space/components/accounts/github-login-button.tsx +++ b/space/components/accounts/github-login-button.tsx @@ -10,9 +10,12 @@ import githubWhiteImage from "public/logos/github-white.svg"; export interface GithubLoginButtonProps { handleSignIn: React.Dispatch; + clientId: string; } -export const GithubLoginButton: FC = ({ handleSignIn }) => { +export const GithubLoginButton: FC = (props) => { + const { handleSignIn, clientId } = props; + // states const [loginCallBackURL, setLoginCallBackURL] = useState(undefined); const [gitCode, setGitCode] = useState(null); @@ -38,7 +41,7 @@ export const GithubLoginButton: FC = ({ handleSignIn })
- {parseInt(process.env.NEXT_PUBLIC_ENABLE_OAUTH || "0") ? ( - <> -

- Sign in to Plane -

-
-
- -
-
- - {/* */} -
+

Sign in to Plane

+ {data?.email_password_login && } + + {data?.magic_login && ( +
+
+
- - ) : ( - +
)} - {parseInt(process.env.NEXT_PUBLIC_ENABLE_OAUTH || "0") ? ( -

- By signing up, you agree to the{" "} - - Terms & Conditions - -

- ) : null} +
+ {data?.google && } +
+ +

+ By signing up, you agree to the{" "} + + Terms & Conditions + +

From 633f2f5516ad71f82f3a6d75e11b394a932131e9 Mon Sep 17 00:00:00 2001 From: sriramveeraghanta Date: Wed, 4 Oct 2023 20:33:16 +0530 Subject: [PATCH 3/3] fix: adding new service --- space/services/app-config.service.ts | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 space/services/app-config.service.ts diff --git a/space/services/app-config.service.ts b/space/services/app-config.service.ts new file mode 100644 index 00000000000..713cda3da1b --- /dev/null +++ b/space/services/app-config.service.ts @@ -0,0 +1,30 @@ +// services +import APIService from "services/api.service"; +// helper +import { API_BASE_URL } from "helpers/common.helper"; + +export interface IEnvConfig { + github: string; + google: string; + github_app_name: string | null; + email_password_login: boolean; + magic_login: boolean; +} + +export class AppConfigService extends APIService { + constructor() { + super(API_BASE_URL); + } + + async envConfig(): Promise { + return this.get("/api/configs/", { + headers: { + "Content-Type": "application/json", + }, + }) + .then((response) => response?.data) + .catch((error) => { + throw error?.response?.data; + }); + } +}