Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not add
from
parameter to URL on signin page when it matches the…
… default redirect Additionally extract redirect logic for ease of reuse
- Loading branch information
Showing
5 changed files
with
38 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@keystone-6/auth': patch | ||
--- | ||
|
||
When redirecting to the homepage, the `from` query parameter unnecessarily displayed `=/`. | ||
This patch fixes that so it is only provided as a query parameter when needed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useMemo } from 'react'; | ||
import { useRouter } from '@keystone-6/core/admin-ui/router'; | ||
|
||
export const useRedirect = () => { | ||
const router = useRouter(); | ||
const redirect = useMemo( | ||
() => | ||
!Array.isArray(router.query.from) && router.query.from?.startsWith('/') | ||
? router.query.from | ||
: '/', | ||
[router] | ||
); | ||
|
||
return redirect; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters