Params fix
This commit is contained in:
parent
786217b753
commit
88fff73cc0
3 changed files with 9 additions and 10 deletions
|
@ -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],
|
||||
|
|
Loading…
Reference in a new issue