|
@ -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 axios from 'axios'; |
|
|
import { React } from 'react'; |
|
|
import { React } from 'react'; |
|
|
import { useDispatch, useSelector } from 'react-redux'; |
|
|
import { useDispatch, useSelector } from 'react-redux'; |
|
@ -16,13 +14,13 @@ function Login() { |
|
|
const isAuthenticated = useSelector(state => state.auth.isAuthenticated); |
|
|
const isAuthenticated = useSelector(state => state.auth.isAuthenticated); |
|
|
if (isAuthenticated) return <Redirect to="/home" />; |
|
|
if (isAuthenticated) return <Redirect to="/home" />; |
|
|
|
|
|
|
|
|
const handleTelegramResponse = (response) => { |
|
|
|
|
|
|
|
|
const handleTelegramResponse = response => { |
|
|
toast({ |
|
|
toast({ |
|
|
title: "Logging you in", |
|
|
|
|
|
|
|
|
title: 'Logging you in', |
|
|
description: "Hold on, we're logging you in.", |
|
|
description: "Hold on, we're logging you in.", |
|
|
status: 'info', |
|
|
status: 'info', |
|
|
duration: 10000, |
|
|
duration: 10000, |
|
|
isClosable: false |
|
|
|
|
|
|
|
|
isClosable: false, |
|
|
}); |
|
|
}); |
|
|
axios |
|
|
axios |
|
|
.post( |
|
|
.post( |
|
@ -38,9 +36,9 @@ function Login() { |
|
|
if (response.data.authorized) { |
|
|
if (response.data.authorized) { |
|
|
dispatch(authLogin()); |
|
|
dispatch(authLogin()); |
|
|
toast.closeAll(); |
|
|
toast.closeAll(); |
|
|
if(response.data.contactSuccess){ |
|
|
|
|
|
|
|
|
if (response.data.contactSuccess) { |
|
|
history.push('/success'); |
|
|
history.push('/success'); |
|
|
}else{ |
|
|
|
|
|
|
|
|
} else { |
|
|
history.push('/home'); |
|
|
history.push('/home'); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
@ -57,8 +55,8 @@ function Login() { |
|
|
}) |
|
|
}) |
|
|
.catch(err => { |
|
|
.catch(err => { |
|
|
toast.closeAll(); |
|
|
toast.closeAll(); |
|
|
if(err.response){ |
|
|
|
|
|
if(err.response.status === 401){ |
|
|
|
|
|
|
|
|
if (err.response) { |
|
|
|
|
|
if (err.response.status === 401) { |
|
|
dispatch(authLogout()); |
|
|
dispatch(authLogout()); |
|
|
toast({ |
|
|
toast({ |
|
|
title: 'Login Failed', |
|
|
title: 'Login Failed', |
|
@ -68,7 +66,7 @@ function Login() { |
|
|
isClosable: true, |
|
|
isClosable: true, |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
}else{ |
|
|
|
|
|
|
|
|
} else { |
|
|
toast({ |
|
|
toast({ |
|
|
title: 'An error occurred', |
|
|
title: 'An error occurred', |
|
|
description: 'Sorry, an error occurred on our side.', |
|
|
description: 'Sorry, an error occurred on our side.', |
|
@ -77,25 +75,56 @@ function Login() { |
|
|
isClosable: true, |
|
|
isClosable: true, |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<Flex |
|
|
<Flex |
|
|
height="100vh" |
|
|
|
|
|
|
|
|
height="100%" |
|
|
background="teal.100" |
|
|
background="teal.100" |
|
|
alignItems="center" |
|
|
alignItems="center" |
|
|
justifyContent="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}> |
|
|
<Heading size="xl" mb={6}> |
|
|
SSR Covid Tracing |
|
|
SSR Covid Tracing |
|
|
</Heading> |
|
|
</Heading> |
|
|
<Heading size="lg" mb={4}> |
|
|
<Heading size="lg" mb={4}> |
|
|
Login |
|
|
Login |
|
|
</Heading> |
|
|
</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> |
|
|
</Flex> |
|
|
</Flex> |
|
|
); |
|
|
); |
|
|