1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-06 01:15:28 +02:00
unleash.unleash/frontend/src/component/user/authentication-simple-component.jsx
Ivar Conradi Østhus 5342c86b60 fix: one and only one front (#244)
Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
2021-02-24 11:03:18 +01:00

51 lines
1.7 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { CardActions, Button, Textfield } from 'react-mdl';
class SimpleAuthenticationComponent extends React.Component {
static propTypes = {
authDetails: PropTypes.object.isRequired,
unsecureLogin: PropTypes.func.isRequired,
loadInitialData: PropTypes.func.isRequired,
history: PropTypes.object.isRequired,
};
handleSubmit = evt => {
evt.preventDefault();
const email = this.refs.email.inputRef.value;
const user = { email };
const path = evt.target.action;
this.props
.unsecureLogin(path, user)
.then(this.props.loadInitialData)
.then(() => this.props.history.push(`/`));
};
render() {
const authDetails = this.props.authDetails;
return (
<form onSubmit={this.handleSubmit} action={authDetails.path}>
<p>{authDetails.message}</p>
<p>
This instance of Unleash is not set up with a secure authentication provider. You can read more
about{' '}
<a href="https://github.com/Unleash/unleash/blob/master/docs/securing-unleash.md" target="_blank">
securing Unleash on GitHub
</a>
</p>
<Textfield label="Email" name="email" required type="email" ref="email" />
<br />
<CardActions style={{ textAlign: 'center' }}>
<Button raised colored>
Sign in
</Button>
</CardActions>
</form>
);
}
}
export default SimpleAuthenticationComponent;