-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
78 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,75 @@ | ||
import React from 'react'; | ||
import React, { useEffect } from 'react'; | ||
|
||
import { Box, Button, Stack, Text } from '@chakra-ui/react'; | ||
import { signIn } from 'next-auth/react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { FiGithub, FiInfo } from 'react-icons/fi'; | ||
import { FiGithub, FiGitlab, FiInfo } from 'react-icons/fi'; | ||
|
||
import { Icon } from '@/components'; | ||
|
||
export const LoginForm = ({ onSuccess = () => undefined, ...rest }: TODO) => { | ||
export const LoginForm = ({ | ||
onSuccess = () => undefined, | ||
provider, | ||
...rest | ||
}: TODO) => { | ||
const { t } = useTranslation(); | ||
useEffect(() => { | ||
if (provider === undefined) { | ||
provider = 'github'; | ||
Check warning on line 18 in src/app/auth/LoginForm.tsx GitHub Actions / Build and Test (14)
Check warning on line 18 in src/app/auth/LoginForm.tsx GitHub Actions / Build and Test (16)
Check warning on line 18 in src/app/auth/LoginForm.tsx GitHub Actions / Build and Test (lts/*)
|
||
} | ||
}, []); | ||
|
||
return ( | ||
<Stack {...rest}> | ||
<Button | ||
w="full" | ||
colorScheme="github" | ||
bg="github.800" | ||
color="white" | ||
leftIcon={<FiGithub />} | ||
ms="auto" | ||
onClick={() => signIn('github')} | ||
> | ||
{t('auth:login.actions.github.login')} | ||
</Button> | ||
<Box borderRadius="md" bg="github.100" color="github.800" p="4"> | ||
<Text> | ||
<Icon icon={FiInfo} /> Only users from{' '} | ||
<Text as="span" fontWeight="medium"> | ||
{process.env.NEXT_PUBLIC_GITHUB_ALLOWED_ORGANIZATIONS} | ||
</Text>{' '} | ||
GitHub organisation(s) will be able to use the application once logged | ||
in. | ||
</Text> | ||
</Box> | ||
</Stack> | ||
<> | ||
{provider === 'github' ? ( | ||
<Stack {...rest}> | ||
<Button | ||
w="full" | ||
colorScheme="github" | ||
bg="github.800" | ||
color="white" | ||
leftIcon={<FiGithub />} | ||
ms="auto" | ||
onClick={() => signIn('github')} | ||
> | ||
{t('auth:login.actions.github.login')} | ||
</Button> | ||
<Box borderRadius="md" bg="github.100" color="github.800" p="4"> | ||
<Text> | ||
<Icon icon={FiInfo} /> Only users from{' '} | ||
<Text as="span" fontWeight="medium"> | ||
{process.env.NEXT_PUBLIC_GITHUB_ALLOWED_ORGANIZATIONS} | ||
</Text>{' '} | ||
GitHub organisation(s) will be able to use the application once | ||
logged in. | ||
</Text> | ||
</Box> | ||
</Stack> | ||
) : ( | ||
<Stack> | ||
<Button | ||
w="full" | ||
colorScheme="gitlab" | ||
bg="github.800" | ||
color="white" | ||
leftIcon={<FiGitlab />} | ||
ms="auto" | ||
onClick={() => signIn('gitlab')} | ||
> | ||
{t('auth:login.actions.gitlab.login')} | ||
</Button> | ||
<Box borderRadius="md" bg="github.100" color="github.800" p="4"> | ||
<Text> | ||
<Icon icon={FiInfo} /> Only users from{' '} | ||
<Text as="span" fontWeight="medium"> | ||
{process.env.NEXT_PUBLIC_GITHUB_ALLOWED_ORGANIZATIONS} | ||
</Text>{' '} | ||
GitLab organisation(s) will be able to use the application once | ||
logged in. | ||
</Text> | ||
</Box> | ||
</Stack> | ||
)} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters