From 931d3a0974ff6f5eb2bf42dd627d8218f18dabaa Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Sun, 13 Dec 2020 14:00:01 +1100 Subject: [PATCH] Fix login redirect to remember current page (#989) --- ui/v2.5/src/components/Changelog/versions/v050.md | 3 +++ ui/v2.5/src/core/createClient.ts | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/v2.5/src/components/Changelog/versions/v050.md b/ui/v2.5/src/components/Changelog/versions/v050.md index 8037c6441..eaf07f18c 100644 --- a/ui/v2.5/src/components/Changelog/versions/v050.md +++ b/ui/v2.5/src/components/Changelog/versions/v050.md @@ -10,3 +10,6 @@ * Use natural sort for titles and movie names. * Support optional preview and sprite generation during scanning. * Support configurable number of threads for scanning and generation. + +### 🐛 Bug fixes +* Fixed login redirect to remember the current page. diff --git a/ui/v2.5/src/core/createClient.ts b/ui/v2.5/src/core/createClient.ts index c64e74fc1..0d40fbe15 100644 --- a/ui/v2.5/src/core/createClient.ts +++ b/ui/v2.5/src/core/createClient.ts @@ -113,7 +113,9 @@ export const createClient = () => { // handle unauthorized error by redirecting to the login page if (networkError && (networkError as ServerError).statusCode === 401) { // redirect to login page - window.location.href = "/login"; + const newURL = new URL("/login", window.location.toString()); + newURL.searchParams.append("returnURL", window.location.href); + window.location.href = newURL.toString(); } });