Skip to content

Commit

Permalink
Added env flag for github oauth option
Browse files Browse the repository at this point in the history
  • Loading branch information
BiswaViraj committed Jun 12, 2022
1 parent 4470db0 commit 7ed431f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 32 deletions.
1 change: 1 addition & 0 deletions apps/web/.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ SKIP_PREFLIGHT_CHECK=true
REACT_APP_API_URL=api_url
REACT_APP_WIDGET_SDK_PATH=sdk_path
REACT_APP_ENVIRONMENT=dev
REACT_APP_GITHUB_AUTH_OPTION=show
33 changes: 18 additions & 15 deletions apps/web/src/components/auth/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { AuthContext } from '../../store/authContext';
import { api } from '../../api/api.client';
import { PasswordInput, Button, colors, Input, Text } from '../../design-system';
import { Github } from '../../design-system/icons';
import { API_ROOT } from '../../config';
import { API_ROOT, GITHUB_AUTH_OPTION } from '../../config';

type Props = {};

Expand Down Expand Up @@ -51,20 +51,23 @@ export function LoginForm({}: Props) {

return (
<>
<GithubButton
component="a"
href={`${API_ROOT}/v1/auth/github`}
my={30}
variant="white"
fullWidth
radius="md"
leftIcon={<Github />}
sx={{ color: colors.B40, fontSize: '16px', fontWeight: '700', height: '50px' }}
>
Sign In with Github
</GithubButton>
<Divider label={<Text color={colors.B40}>Or</Text>} color={colors.B30} labelPosition="center" my="md" />

{GITHUB_AUTH_OPTION && (
<>
<GithubButton
component="a"
href={`${API_ROOT}/v1/auth/github`}
my={30}
variant="white"
fullWidth
radius="md"
leftIcon={<Github />}
sx={{ color: colors.B40, fontSize: '16px', fontWeight: '700', height: '50px' }}
>
Sign In with Github
</GithubButton>
<Divider label={<Text color={colors.B40}>Or</Text>} color={colors.B30} labelPosition="center" my="md" />
</>
)}
<form onSubmit={handleSubmit(onLogin)}>
<Input
error={errors.email?.message}
Expand Down
34 changes: 17 additions & 17 deletions apps/web/src/components/auth/SignUpForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { AuthContext } from '../../store/authContext';
import { api } from '../../api/api.client';
import { PasswordInput, Button, colors, Input, Text } from '../../design-system';
import { Github } from '../../design-system/icons';
import { API_ROOT } from '../../config';
import { API_ROOT, GITHUB_AUTH_OPTION } from '../../config';
import { showNotification } from '@mantine/notifications';

type Props = {
Expand Down Expand Up @@ -84,22 +84,22 @@ export function SignUpForm({ token, email }: Props) {

return (
<>
{!token && (
<GithubButton
my={30}
component="a"
href={`${API_ROOT}/v1/auth/github`}
variant="white"
fullWidth
radius="md"
leftIcon={<Github />}
sx={{ color: colors.B40, fontSize: '16px', fontWeight: '700', height: '50px' }}
>
Sign Up with Github
</GithubButton>
)}
{!token && (
<Divider label={<Text color={colors.B40}>Or</Text>} color={colors.B30} labelPosition="center" my="md" />
{GITHUB_AUTH_OPTION && !token && (
<>
<GithubButton
my={30}
component="a"
href={`${API_ROOT}/v1/auth/github`}
variant="white"
fullWidth
radius="md"
leftIcon={<Github />}
sx={{ color: colors.B40, fontSize: '16px', fontWeight: '700', height: '50px' }}
>
Sign Up with Github
</GithubButton>
<Divider label={<Text color={colors.B40}>Or</Text>} color={colors.B30} labelPosition="center" my="md" />
</>
)}

<form name="login-form" onSubmit={handleSubmit(onSubmit)}>
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ export const ENV = process.env.REACT_APP_ENVIRONMENT;
export const APP_ID = process.env.REACT_APP_NOVU_APP_ID;

export const WIDGET_EMEBED_PATH = process.env.REACT_APP_WIDGET_EMBED_PATH || 'https://localhost:4701/embed.umd.min.js';

export const GITHUB_AUTH_OPTION = process.env.REACT_APP_GITHUB_AUTH_OPTION === 'show';
3 changes: 3 additions & 0 deletions docker/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ API_ROOT_URL=https://localhost:3000
FRONT_BASE_URL=https://client:4200
WIDGET_EMBED_PATH=https://localhost:4701/embed.umd.min.js
WIDGET_URL=https://localhost:4500

# Github Auth Option
REACT_APP_GITHUB_AUTH_OPTION=hide
1 change: 1 addition & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ services:
REACT_APP_API_URL: ${API_ROOT_URL}
REACT_APP_ENVIRONMENT: ${NODE_ENV}
REACT_APP_WIDGET_EMBED_PATH: ${WIDGET_EMBED_PATH}
REACT_APP_GITHUB_AUTH_OPTION: ${REACT_APP_GITHUB_AUTH_OPTION}
ports:
- 4200:4200
volumes:
Expand Down

0 comments on commit 7ed431f

Please sign in to comment.