Fix login redirect on from parameter on React login page

This commit is contained in:
Aurora Lahtela 2022-08-28 18:17:25 +03:00
parent 4ff06e22e5
commit cc326ddb84

View File

@ -12,6 +12,7 @@ import drawSine from "../../util/loginSineRenderer";
import {fetchLogin} from "../../service/authenticationService";
import ForgotPasswordModal from "../../components/modal/ForgotPasswordModal";
import {useAuth} from "../../hooks/authenticationHook";
import {baseAddress} from "../../service/backendConfiguration";
const Logo = () => {
return (
@ -163,11 +164,11 @@ const LoginPage = () => {
setFailMessage(t('html.login.failed') + (error.data && error.data.error ? error.data.error : error.message));
}
} else if (data && data.success) {
await updateLoginDetails();
if (redirectTo && !redirectTo.startsWith('http') && !redirectTo.startsWith('file') && !redirectTo.startsWith('javascript')) {
navigate(redirectTo.substring(redirectTo.indexOf('/')))
navigate(baseAddress + redirectTo.substring(redirectTo.indexOf('/')) + (window.location.hash ? window.location.hash : ''));
} else {
await updateLoginDetails();
navigate('../');
navigate(baseAddress + '/');
}
} else {
setFailMessage(t('html.login.failed') + data ? data.error : t('generic.noData'));