|
|
@ -1,6 +1,4 @@ |
|
|
|
import { |
|
|
|
Flex, Heading, useToast |
|
|
|
} from '@chakra-ui/react'; |
|
|
|
import { Divider, Flex, Heading, Link, Text, useToast } from '@chakra-ui/react'; |
|
|
|
import axios from 'axios'; |
|
|
|
import { React } from 'react'; |
|
|
|
import { useDispatch, useSelector } from 'react-redux'; |
|
|
@ -16,13 +14,13 @@ function Login() { |
|
|
|
const isAuthenticated = useSelector(state => state.auth.isAuthenticated); |
|
|
|
if (isAuthenticated) return <Redirect to="/home" />; |
|
|
|
|
|
|
|
const handleTelegramResponse = (response) => { |
|
|
|
const handleTelegramResponse = response => { |
|
|
|
toast({ |
|
|
|
title: "Logging you in", |
|
|
|
title: 'Logging you in', |
|
|
|
description: "Hold on, we're logging you in.", |
|
|
|
status: 'info', |
|
|
|
duration: 10000, |
|
|
|
isClosable: false |
|
|
|
isClosable: false, |
|
|
|
}); |
|
|
|
axios |
|
|
|
.post( |
|
|
@ -38,9 +36,9 @@ function Login() { |
|
|
|
if (response.data.authorized) { |
|
|
|
dispatch(authLogin()); |
|
|
|
toast.closeAll(); |
|
|
|
if(response.data.contactSuccess){ |
|
|
|
if (response.data.contactSuccess) { |
|
|
|
history.push('/success'); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
history.push('/home'); |
|
|
|
} |
|
|
|
} else { |
|
|
@ -57,8 +55,8 @@ function Login() { |
|
|
|
}) |
|
|
|
.catch(err => { |
|
|
|
toast.closeAll(); |
|
|
|
if(err.response){ |
|
|
|
if(err.response.status === 401){ |
|
|
|
if (err.response) { |
|
|
|
if (err.response.status === 401) { |
|
|
|
dispatch(authLogout()); |
|
|
|
toast({ |
|
|
|
title: 'Login Failed', |
|
|
@ -68,7 +66,7 @@ function Login() { |
|
|
|
isClosable: true, |
|
|
|
}); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
toast({ |
|
|
|
title: 'An error occurred', |
|
|
|
description: 'Sorry, an error occurred on our side.', |
|
|
@ -77,25 +75,56 @@ function Login() { |
|
|
|
isClosable: true, |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
return ( |
|
|
|
<Flex |
|
|
|
height="100vh" |
|
|
|
height="100%" |
|
|
|
background="teal.100" |
|
|
|
alignItems="center" |
|
|
|
justifyContent="center" |
|
|
|
> |
|
|
|
<Flex direction="column" background="white" p={12} rounded={6}> |
|
|
|
<Flex |
|
|
|
direction="column" |
|
|
|
mt={5} |
|
|
|
mb={5} |
|
|
|
background="white" |
|
|
|
p={12} |
|
|
|
rounded={6} |
|
|
|
id="contentFlex" |
|
|
|
> |
|
|
|
<Heading size="xl" mb={6}> |
|
|
|
SSR Covid Tracing |
|
|
|
</Heading> |
|
|
|
<Heading size="lg" mb={4}> |
|
|
|
Login |
|
|
|
</Heading> |
|
|
|
<TelegramLoginButton dataOnauth={handleTelegramResponse} botName={process.env.REACT_APP_TELEGRAM_BOT_NAME} /> |
|
|
|
<TelegramLoginButton |
|
|
|
dataOnauth={handleTelegramResponse} |
|
|
|
botName={process.env.REACT_APP_TELEGRAM_BOT_NAME} |
|
|
|
/> |
|
|
|
<Divider mb={6} mt={6} /> |
|
|
|
<Text fontSize="sm"> |
|
|
|
<b>Privacy notes:</b> <br /> |
|
|
|
Telegram Login allows us to verify your identity, without collecting |
|
|
|
any of your data. Telegram does NOT give us your phone number. The |
|
|
|
only piece of information stored on our server is your Telegram ID, |
|
|
|
this is an internal ID Number Telegram uses that is SEPARATE from your |
|
|
|
Telegram Username. |
|
|
|
<br /> |
|
|
|
<br /> |
|
|
|
All the code for this project is{' '} |
|
|
|
<Link |
|
|
|
color="teal.500" |
|
|
|
href="https://github.com/naresh97/ssr-tracing" |
|
|
|
isExternal |
|
|
|
> |
|
|
|
Open Source |
|
|
|
</Link> |
|
|
|
, that means anyone, including you can audit and verify that your |
|
|
|
information is being handled securely. |
|
|
|
</Text> |
|
|
|
</Flex> |
|
|
|
</Flex> |
|
|
|
); |
|
|
|