-
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.
* fix add endpoints to use grpcWrapper * add login page and auth token * PR comment * add wrapper function for token
- Loading branch information
1 parent
b5a613a
commit 0e344e7
Showing
18 changed files
with
229 additions
and
96 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
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
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 |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import React, { useState } from 'react'; | ||
import { push } from 'connected-react-router'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import styled from 'styled-components'; | ||
import { VerticalSpacer } from 'components/atoms/Spacer'; | ||
import SolidIconButton from 'components/atoms/SolidIconButton'; | ||
import { useDispatch } from 'react-redux'; | ||
import { Formik, FormikProps } from 'formik'; | ||
import { bps } from 'theme'; | ||
import FormikTextField from 'components/atoms/FormikTextField'; | ||
import DoneButton from '../atoms/DoneButton'; | ||
import { updateToken } from '../../states/auth/actions'; | ||
import { PATH_APP } from '../../libraries/constants'; | ||
|
||
|
||
const StyledDiv = styled.div` | ||
box-sizing: border-box; | ||
padding-top: 35%; | ||
padding-left: 40px; | ||
padding-right: 40px; | ||
${bps.down('sm')} { | ||
padding: 40% 20px 0 20px; | ||
} | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
.retry-button { | ||
width: 140px; | ||
} | ||
`; | ||
|
||
interface LoginProps { | ||
secret: string; | ||
} | ||
|
||
const LoginPage = () => { | ||
const dispatch = useDispatch(); | ||
const [loggedIn, setLoggedIn] = useState(false); | ||
return ( | ||
<StyledDiv> | ||
<Typography variant="h1">Provide your credential :) </Typography> | ||
<VerticalSpacer size={32} /> | ||
<Typography variant="h4"> | ||
Looks like you have enabled authentication on kinto-core. | ||
</Typography> | ||
<VerticalSpacer size={32} /> | ||
|
||
<Formik<LoginProps> | ||
initialValues={{ | ||
secret: '', | ||
}} | ||
onSubmit={(values, { setSubmitting }) => { | ||
setSubmitting(true); | ||
dispatch(updateToken(values.secret)); | ||
setTimeout(() => { | ||
setLoggedIn(true); | ||
setSubmitting(false); | ||
dispatch(push(PATH_APP)); | ||
}, 800); | ||
}} | ||
> | ||
{({ handleSubmit, isSubmitting }: FormikProps<any>) => { | ||
return ( | ||
<form onSubmit={handleSubmit}> | ||
<div> | ||
<FormikTextField | ||
label="secret" | ||
name="secret" | ||
variant="outlined" | ||
placeholder="The KINTO_CORE_SECRET you set on kinto-core" | ||
fullWidth | ||
/> | ||
<VerticalSpacer size={32} /> | ||
<div> | ||
{loggedIn ? ( | ||
<DoneButton | ||
noPadding | ||
data-cy="login-success-button" | ||
text="Done" | ||
/> | ||
) : ( | ||
<SolidIconButton | ||
data-cy="login-button" | ||
text="LOGIN" | ||
size="large" | ||
isLoading={isSubmitting} | ||
type="submit" | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
</form> | ||
); | ||
}} | ||
</Formik> | ||
</StyledDiv> | ||
); | ||
}; | ||
|
||
export default LoginPage; |
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
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
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
Oops, something went wrong.