Added redirect on unauthorized route BOD-162
This commit is contained in:
@@ -1,23 +1,24 @@
|
||||
import { LockOutlined, UserOutlined } from "@ant-design/icons";
|
||||
import { Button, Form, Input, Typography } from "antd";
|
||||
import queryString from "query-string";
|
||||
import React from "react";
|
||||
import { useApolloClient } from "react-apollo";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { Redirect, Link } from "react-router-dom";
|
||||
import { Link, Redirect, useLocation } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import ImEXOnlineLogo from "../../assets/logo240.png";
|
||||
import { UPSERT_USER } from "../../graphql/user.queries";
|
||||
import {
|
||||
emailSignInStart,
|
||||
sendPasswordReset,
|
||||
sendPasswordReset
|
||||
} from "../../redux/user/user.actions";
|
||||
import {
|
||||
selectCurrentUser,
|
||||
selectSignInError,
|
||||
selectSignInError
|
||||
} from "../../redux/user/user.selectors";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import "./sign-in-form.styles.scss";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import "./sign-in-form.styles.scss";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
@@ -36,6 +37,7 @@ export function SignInComponent({
|
||||
signInError,
|
||||
sendPasswordReset,
|
||||
}) {
|
||||
const { redirect } = queryString.parse(useLocation().search);
|
||||
const apolloClient = useApolloClient();
|
||||
const { t } = useTranslation();
|
||||
const handleFinish = (values) => {
|
||||
@@ -60,7 +62,8 @@ export function SignInComponent({
|
||||
});
|
||||
}
|
||||
|
||||
if (currentUser.authorized === true) return <Redirect to='/manage' />;
|
||||
if (currentUser.authorized === true)
|
||||
return <Redirect to={redirect || "/manage"} />;
|
||||
|
||||
return (
|
||||
<div className='login-container'>
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
import { Button, Form, Result } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import {
|
||||
sendPasswordReset,
|
||||
validatePasswordResetStart,
|
||||
} from "../../redux/user/user.actions";
|
||||
import queryString from "query-string";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { Input, Form, Button, Result } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import EmailFormItemComponent from "../form-items-formatted/email-form-item.component";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { sendPasswordReset } from "../../redux/user/user.actions";
|
||||
import { selectPasswordReset } from "../../redux/user/user.selectors";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import EmailFormItemComponent from "../form-items-formatted/email-form-item.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
passwordReset: selectPasswordReset,
|
||||
|
||||
Reference in New Issue
Block a user