Skip to content

Commit

Permalink
Merge pull request #5248 from bardeutsch/fix-redirect-url-after-login
Browse files Browse the repository at this point in the history
Changed code to use pathName first (if exists) for redirect after login
  • Loading branch information
jdemangeon authored Sep 16, 2020
2 parents d1aef1d + 2bc73cf commit 5379985
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/ra-core/src/auth/useLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 5379985

Please sign in to comment.