feat(ui) - sso login jwt
This commit is contained in:
parent
ecd631345b
commit
c97c1ada29
2 changed files with 22 additions and 3 deletions
|
|
@ -4,29 +4,41 @@ import { Icon, Loader, Button, Link } 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.css';
|
||||
import cn from 'classnames';
|
||||
import { setJwt } from 'Duck/jwt';
|
||||
|
||||
const FORGOT_PASSWORD = forgotPassword();
|
||||
const SIGNUP_ROUTE = signup();
|
||||
const recaptchaRef = React.createRef();
|
||||
|
||||
@connect(
|
||||
state => ({
|
||||
(state, props) => ({
|
||||
errors: state.getIn([ 'user', 'loginRequest', 'errors' ]),
|
||||
loading: state.getIn([ 'user', 'loginRequest', 'loading' ]),
|
||||
// existingTenant: state.getIn(['user', 'authDetails', 'tenants']),
|
||||
authDetails: state.getIn(['user', 'authDetails']),
|
||||
params: new URLSearchParams(props.location.search)
|
||||
}),
|
||||
{ login, },
|
||||
{ login, setJwt },
|
||||
)
|
||||
@withPageTitle('Login - OpenReplay')
|
||||
@withRouter
|
||||
export default class Login extends React.Component {
|
||||
state = {
|
||||
email: '',
|
||||
password: '',
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
const { params } = this.props;
|
||||
const jwt = params.get('jwt')
|
||||
if (jwt) {
|
||||
this.props.setJwt(jwt);
|
||||
window.location.href = '/';
|
||||
}
|
||||
}
|
||||
|
||||
handleSubmit = (token) => {
|
||||
const { email, password } = this.state;
|
||||
this.props.login({ email: email.trim(), password, 'g-recaptcha-response': token }).then(() => {
|
||||
|
|
|
|||
|
|
@ -10,3 +10,10 @@ export default (state = null, action = {}) => {
|
|||
}
|
||||
return state;
|
||||
};
|
||||
|
||||
export function setJwt(data) {
|
||||
return {
|
||||
type: UPDATE,
|
||||
data,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue