Skip to content
Snippets Groups Projects
Commit 88fff73c authored by Valentino Kozinec's avatar Valentino Kozinec
Browse files

Params fix

parent 786217b7
No related branches found
No related tags found
No related merge requests found
Pipeline #11216 passed with stages
in 3 minutes and 51 seconds
......@@ -8,15 +8,14 @@ type LoginCallbackProps = RouteComponentProps;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function LoginCallback(_: LoginCallbackProps) {
const currentURL = window.location.href;
const urlParams = new URLSearchParams(currentURL);
const state = urlParams.get('state');
const indexOfQuestionMark = currentURL.indexOf('?');
const params = currentURL.slice(indexOfQuestionMark);
const { logIn } = useAuth();
useEffect(() => {
if (state) {
const res = logIn(state);
if (params) {
const res = logIn(params);
// @ts-ignore
if (res.ok) {
showToast('Logged in');
......@@ -25,7 +24,7 @@ export function LoginCallback(_: LoginCallbackProps) {
navigate('/login');
}
}
}, [logIn, state]);
}, [logIn, params]);
return (
<div className="min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8">
......
......@@ -7,8 +7,8 @@ export function useAuth() {
const auth = useSelector(getAuth);
const logIn = useCallback(
(state) => {
return dispatch(signIn(state));
(params) => {
return dispatch(signIn(params));
},
[dispatch],
);
......
......@@ -15,10 +15,10 @@ const signOutAction = (): SuccessAction => ({
payload: null,
});
export const signIn = (state: string) =>
export const signIn = (params: string) =>
createApiAction(
{
path: `/hydra/callback?state=${state}`,
path: `/hydra/callback${params}`,
method: 'GET',
},
[AuthActionTypes.SIGN_IN_START, AuthActionTypes.SIGN_IN_SUCCESS, AuthActionTypes.SIGN_IN_FAILURE],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment