mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-03 08:10:27 +00:00
fix: only send the default account itself to the replace step
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f5d09365bd
commit
8cbf1fc6a9
@@ -1,7 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { Button } from '$lib/components/common'
|
||||
import { classes as alertClasses, icons as alertIcons } from '$lib/components/common/alert/model'
|
||||
import { superadminSettingsHref } from '$lib/components/sidebar/settings'
|
||||
import { superadmin } from '$lib/stores'
|
||||
import {
|
||||
DEFAULT_SUPERADMIN_EMAIL,
|
||||
isDefaultSuperadminActive,
|
||||
REPLACE_DEFAULT_SUPERADMIN_HREF
|
||||
} from '$lib/defaultSuperadmin'
|
||||
@@ -13,6 +16,10 @@
|
||||
let active = $state(false)
|
||||
isDefaultSuperadminActive().then((v) => (active = v))
|
||||
|
||||
// The replace step deletes the signed-in account, so another superadmin is sent to the
|
||||
// instance users list to remove admin@windmill.dev instead.
|
||||
let signedInAsDefault = $derived($superadmin === DEFAULT_SUPERADMIN_EMAIL)
|
||||
|
||||
const palette = alertClasses.error
|
||||
const Icon = alertIcons.error
|
||||
</script>
|
||||
@@ -24,11 +31,17 @@
|
||||
>
|
||||
<Icon size={16} class="shrink-0 {palette.iconClass}" />
|
||||
<span class="text-xs font-medium {palette.titleClass}">
|
||||
The default superadmin account admin@windmill.dev / changeme is still active. Anyone who can
|
||||
reach this instance can log in with it.
|
||||
The default superadmin account {DEFAULT_SUPERADMIN_EMAIL} / changeme is still active. Anyone who
|
||||
can reach this instance can log in with it.
|
||||
</span>
|
||||
<Button variant="default" unifiedSize="xs" href={REPLACE_DEFAULT_SUPERADMIN_HREF}>
|
||||
Replace account
|
||||
</Button>
|
||||
{#if signedInAsDefault}
|
||||
<Button variant="default" unifiedSize="xs" href={REPLACE_DEFAULT_SUPERADMIN_HREF}>
|
||||
Replace account
|
||||
</Button>
|
||||
{:else}
|
||||
<Button variant="default" unifiedSize="xs" href={superadminSettingsHref('users')}>
|
||||
Manage instance users
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { UserService } from '$lib/gen'
|
||||
|
||||
/** The quick setup's step that replaces the default superadmin account. */
|
||||
export const DEFAULT_SUPERADMIN_EMAIL = 'admin@windmill.dev'
|
||||
|
||||
/** The quick setup's step that replaces the default superadmin account. That step deletes
|
||||
* the signed-in account, so only send the default account itself there. */
|
||||
export const REPLACE_DEFAULT_SUPERADMIN_HREF = '/user/instance_settings?step=account'
|
||||
|
||||
/** Whether admin@windmill.dev can still sign in with changeme. Superadmin-only endpoint. */
|
||||
@@ -12,3 +15,13 @@ export async function isDefaultSuperadminActive(): Promise<boolean> {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/** Whether the signed-in user is the default account and it still has its default password. */
|
||||
export async function isSignedInAsActiveDefaultSuperadmin(): Promise<boolean> {
|
||||
try {
|
||||
if ((await UserService.getCurrentEmail()) !== DEFAULT_SUPERADMIN_EMAIL) return false
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
return isDefaultSuperadminActive()
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { Button } from '$lib/components/common'
|
||||
import DefaultSuperadminSkipModal from '$lib/components/DefaultSuperadminSkipModal.svelte'
|
||||
import {
|
||||
isDefaultSuperadminActive,
|
||||
isSignedInAsActiveDefaultSuperadmin,
|
||||
REPLACE_DEFAULT_SUPERADMIN_HREF
|
||||
} from '$lib/defaultSuperadmin'
|
||||
import { goto } from '$lib/navigation'
|
||||
@@ -17,7 +17,7 @@
|
||||
let showSkipWarning = $state(false)
|
||||
|
||||
async function skip() {
|
||||
if (await isDefaultSuperadminActive()) {
|
||||
if (await isSignedInAsActiveDefaultSuperadmin()) {
|
||||
showSkipWarning = true
|
||||
} else {
|
||||
goto('/user/workspaces')
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
import ConfirmationModal from '$lib/components/common/confirmationModal/ConfirmationModal.svelte'
|
||||
import InstanceAISettings from '$lib/components/instanceSettings/InstanceAISettings.svelte'
|
||||
import DefaultSuperadminSkipModal from '$lib/components/DefaultSuperadminSkipModal.svelte'
|
||||
import { isDefaultSuperadminActive } from '$lib/defaultSuperadmin'
|
||||
import { isSignedInAsActiveDefaultSuperadmin } from '$lib/defaultSuperadmin'
|
||||
|
||||
const settingsSteps = [
|
||||
{ id: 'Core', label: 'Core' },
|
||||
@@ -277,7 +277,7 @@
|
||||
let showSkipWarning = $state(false)
|
||||
|
||||
async function skipSetup() {
|
||||
if (await isDefaultSuperadminActive()) {
|
||||
if (await isSignedInAsActiveDefaultSuperadmin()) {
|
||||
showSkipWarning = true
|
||||
} else {
|
||||
finishSetup()
|
||||
|
||||
Reference in New Issue
Block a user