diff --git a/frontend/app/components/Login/Login.js b/frontend/app/components/Login/Login.js deleted file mode 100644 index 69c8fb521..000000000 --- a/frontend/app/components/Login/Login.js +++ /dev/null @@ -1,224 +0,0 @@ -import React from 'react'; -import { connect } from 'react-redux'; -import withPageTitle from 'HOCs/withPageTitle'; -import { Icon, Loader, Button, Link, Input, Form, Popover, Tooltip } from 'UI'; -import { login } from 'Duck/user'; -import { forgotPassword, signup } from 'App/routes'; -import ReCAPTCHA from 'react-google-recaptcha'; -import { withRouter } from 'react-router-dom'; -import stl from './login.module.css'; -import cn from 'classnames'; -import { setJwt } from 'Duck/user'; -import LoginBg from '../../svg/login-illustration.svg'; -import { ENTERPRISE_REQUEIRED } from 'App/constants'; -import { fetchTenants } from 'Duck/user'; -import Copyright from 'Shared/Copyright'; - -const FORGOT_PASSWORD = forgotPassword(); -const SIGNUP_ROUTE = signup(); -const recaptchaRef = React.createRef(); - -export default -@connect( - (state, props) => ({ - errors: state.getIn(['user', 'loginRequest', 'errors']), - loading: state.getIn(['user', 'loginRequest', 'loading']), - authDetails: state.getIn(['user', 'authDetails']), - params: new URLSearchParams(props.location.search), - }), - { login, setJwt, fetchTenants } -) -@withPageTitle('Login - OpenReplay') -@withRouter -class Login extends React.Component { - state = { - email: '', - password: '', - CAPTCHA_ENABLED: window.env.CAPTCHA_ENABLED === 'true', - }; - - static getDerivedStateFromProps(nextProps, prevState) { - const { authDetails } = nextProps; - if (Object.keys(authDetails).length === 0) { - return null; - } - - if (!authDetails.tenants) { - nextProps.history.push(SIGNUP_ROUTE); - } - - return null; - } - - componentDidMount() { - const { params } = this.props; - this.props.fetchTenants(); - const jwt = params.get('jwt'); - if (jwt) { - this.props.setJwt(jwt); - } - } - - handleSubmit = (token) => { - const { email, password } = this.state; - this.props.login({ email: email.trim(), password, 'g-recaptcha-response': token }); - }; - - onSubmit = (e) => { - e.preventDefault(); - const { CAPTCHA_ENABLED } = this.state; - if (CAPTCHA_ENABLED && recaptchaRef.current) { - recaptchaRef.current.execute(); - } else if (!CAPTCHA_ENABLED) { - this.handleSubmit(); - } - }; - - write = ({ target: { value, name } }) => this.setState({ [name]: value }); - - render() { - const { errors, loading, authDetails } = this.props; - const { CAPTCHA_ENABLED } = this.state; - - return ( -
-
-
- -
-
-

- Login to your account -

-
-
- - {CAPTCHA_ENABLED && ( - this.handleSubmit(token)} - /> - )} -
- - - - - - - - -
-
- {errors && errors.length ? ( -
- {errors.map((error) => ( -
- - - {error} -
-
-
- ))} -
- ) : null} - -
- - -
- Having trouble logging in?{' '} - - {'Reset password'} - -
-
-
- -
- {authDetails.sso ? ( - - - - ) : ( - - {authDetails.edition === 'ee' ? ( - - SSO has not been configured.
Please reach out to your admin. -
- ) : ( - ENTERPRISE_REQUEIRED - )} -
- } - placement="top" - > - - - )} -
-
-
- - - -
-
-
- - - - ); - } -}