mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-12 00:06:14 +00:00
improve cookie handling for cloud apps
This commit is contained in:
@@ -47,7 +47,6 @@ use windmill_common::users::COOKIE_NAME;
|
||||
use windmill_common::users::{truncate_token, username_to_permissioned_as};
|
||||
use windmill_common::utils::paginate;
|
||||
use windmill_common::worker::CLOUD_HOSTED;
|
||||
use windmill_common::BASE_URL;
|
||||
use windmill_common::{
|
||||
auth::{get_folders_for_user, get_groups_for_user},
|
||||
db::UserDB,
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
import { clearStores } from '$lib/storeUtils'
|
||||
import { setLicense } from '$lib/enterpriseUtils'
|
||||
import Login from '$lib/components/Login.svelte'
|
||||
import { onMount } from 'svelte'
|
||||
|
||||
const email = $page.url.searchParams.get('email') ?? ''
|
||||
const password = $page.url.searchParams.get('password') ?? ''
|
||||
@@ -21,6 +22,26 @@
|
||||
let showPassword = false
|
||||
let firstTime = false
|
||||
|
||||
function clearWindmillCloudCookies() {
|
||||
const domain = window.location.hostname
|
||||
// Check if the domain ends with ".windmill.dev" but is NOT "app.windmill.dev"
|
||||
if (
|
||||
domain.endsWith('.windmill.dev') &&
|
||||
domain !== 'app.windmill.dev' &&
|
||||
domain !== 'internal.windmill.dev'
|
||||
) {
|
||||
// Remove the "token" cookie for the current domain and its parent domain
|
||||
document.cookie = `token=; domain=.windmill.dev; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC; Secure; SameSite=None`
|
||||
document.cookie = `token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC; Secure; SameSite=None`
|
||||
|
||||
console.log('Token cookie removed for windmill cloud instance.')
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
clearWindmillCloudCookies()
|
||||
})
|
||||
|
||||
async function redirectUser() {
|
||||
if (rd?.startsWith('http')) {
|
||||
window.location.href = rd
|
||||
@@ -80,7 +101,6 @@
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
setLicense()
|
||||
redirectIfNecessary()
|
||||
checkFirstTimeSetup()
|
||||
|
||||
Reference in New Issue
Block a user