fix redirect at login

This commit is contained in:
Ruben Fiszel
2022-08-07 12:17:04 +02:00
parent 2c6f1c3b82
commit b0435ada43
2 changed files with 2 additions and 4 deletions
+1 -3
View File
@@ -1,7 +1,5 @@
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import { UserService } from '$lib/gen'
import { get } from 'svelte/store'
import { clearStores } from './stores.js'
import { sendUserToast } from './utils.js'
@@ -9,7 +7,7 @@ function clearCookies() {
document.cookie.split(";").forEach(function (c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/") })
}
export function logoutWithRedirect(rd?: string): void {
if (get(page).url.pathname != '/user/login') {
if (rd?.split('?')[0] != '/user/login') {
const error = document.cookie.includes('token')
? `error=${encodeURIComponent('You have been logged out because your session has expired.')}&`
: ''
+1 -1
View File
@@ -51,7 +51,7 @@
if ($workspaceStore) {
goto(rd ?? '/')
} else {
goto('/user/workspaces')
goto(`/user/workspaces${rd ? `?rd=${encodeURIComponent(rd)}` : ''}`)
}
}