mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-20 08:01:35 +00:00
rework logout
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
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'
|
||||
|
||||
@@ -7,11 +9,13 @@ function clearCookies() {
|
||||
document.cookie.split(";").forEach(function (c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/") })
|
||||
}
|
||||
export function logoutWithRedirect(rd?: string): void {
|
||||
const error = document.cookie.includes('token')
|
||||
? `error=${encodeURIComponent('You have been logged out because your session has expired.')}&`
|
||||
: ''
|
||||
clearCookies()
|
||||
goto(`/user/login?${error}${rd ? 'rd=' + encodeURIComponent(rd) : ''}`)
|
||||
if (get(page).url.pathname != '/user/login') {
|
||||
const error = document.cookie.includes('token')
|
||||
? `error=${encodeURIComponent('You have been logged out because your session has expired.')}&`
|
||||
: ''
|
||||
clearCookies()
|
||||
goto(`/user/login?${error}${rd ? 'rd=' + encodeURIComponent(rd) : ''}`)
|
||||
}
|
||||
}
|
||||
|
||||
export async function logout(): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user