diff --git a/packages/ra-core/src/auth/useLogin.ts b/packages/ra-core/src/auth/useLogin.ts index 6af8f2d8f0d..e2be295c9bb 100644 --- a/packages/ra-core/src/auth/useLogin.ts +++ b/packages/ra-core/src/auth/useLogin.ts @@ -34,9 +34,12 @@ const useLogin = (): Login => { const nextPathName = locationState && locationState.nextPathname; const login = useCallback( - (params: any = {}, pathName = defaultAuthParams.afterLoginUrl) => + (params: any = {}, pathName) => authProvider.login(params).then(ret => { - history.push(nextPathName || pathName); + const redirectUrl = pathName + ? pathName + : nextPathName || defaultAuthParams.afterLoginUrl; + history.push(redirectUrl); return ret; }), [authProvider, history, nextPathName]