Login: fix access for auth user

This commit is contained in:
Viktor Fomin 2022-10-20 15:32:20 +05:00
parent 76ba5fdf98
commit d2fe1b8e9b
3 changed files with 7 additions and 7 deletions

View File

@ -96,6 +96,7 @@ declare global {
capabilities: ICapabilities;
match: MatchType;
currentColorScheme: ITheme;
isAuth: boolean;
}
interface DevRequest {

View File

@ -24,7 +24,6 @@ import SSOIcon from "../../../../../public/images/sso.react.svg";
interface ILoginProps extends IInitialState {
isDesktopEditor?: boolean;
isAuth: boolean;
}
const Login: React.FC<ILoginProps> = ({
portalSettings,
@ -33,7 +32,6 @@ const Login: React.FC<ILoginProps> = ({
capabilities,
isDesktopEditor,
match,
isAuth,
currentColorScheme,
theme,
}) => {
@ -46,10 +44,6 @@ const Login: React.FC<ILoginProps> = ({
const { t } = useTranslation(["Login", "Common"]);
useEffect(() => {
if (isAuth) window.location.href = "/";
}, []);
const ssoExists = () => {
if (ssoUrl) return true;
else return false;

View File

@ -31,7 +31,7 @@ app.use("/login", express.static(path.resolve(path.join(__dirname, "client"))));
app.use(logger("dev", { stream: stream }));
app.get("*", async (req: ILoginRequest, res: Response) => {
app.get("*", async (req: ILoginRequest, res: Response, next) => {
const { i18n, cookies, headers, query, t, url } = req;
let initialState: IInitialState;
let assets: assetsType;
@ -41,6 +41,11 @@ app.get("*", async (req: ILoginRequest, res: Response) => {
try {
initialState = await getInitialState(query);
if (initialState.isAuth) {
res.redirect('/');
next();
}
let currentLanguage = initialState.portalSettings.culture;
if (cookies && cookies[LANGUAGE]) {