Allow change_workspace_id on CLOUD_HOSTED for superadmins (#6073)
* feat: allow change_workspace_id on CLOUD_HOSTED for superadmins - Import is_super_admin_email function from windmill_common::auth - Modify CLOUD_HOSTED restriction to bypass for superadmin users - Resolves request to allow workspace ID changes for superadmins only Co-authored-by: Ruben Fiszel <rubenfiszel@users.noreply.github.com> * feat: allow superadmins to change workspace ID on cloud hosted environments Update frontend conditional logic to show workspace ID change button for superadmins on cloud hosted environments. This complements the backend changes that already allow superadmins to perform the workspace ID change operation. Changes: - Add superadmin import from $lib/stores - Update condition from `!isCloudHosted()` to `!isCloudHosted() || $superadmin` Co-authored-by: Ruben Fiszel <rubenfiszel@users.noreply.github.com> --------- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: Ruben Fiszel <rubenfiszel@users.noreply.github.com>
This commit is contained in:
@@ -14,6 +14,7 @@ use windmill_audit::ActionKind;
|
||||
use windmill_common::worker::CLOUD_HOSTED;
|
||||
|
||||
use windmill_common::{
|
||||
auth::is_super_admin_email,
|
||||
error::{Error, Result},
|
||||
utils::require_admin,
|
||||
};
|
||||
@@ -32,7 +33,7 @@ pub(crate) async fn change_workspace_id(
|
||||
Extension(db): Extension<DB>,
|
||||
Json(rw): Json<ChangeWorkspaceId>,
|
||||
) -> Result<String> {
|
||||
if *CLOUD_HOSTED {
|
||||
if *CLOUD_HOSTED && !is_super_admin_email(&db, &authed.email).await? {
|
||||
return Err(Error::BadRequest(
|
||||
"This feature is not available on the cloud".to_string(),
|
||||
));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import { workspaceStore, superadmin } from '$lib/stores'
|
||||
import Alert from '../common/alert/Alert.svelte'
|
||||
import Button from '../common/button/Button.svelte'
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
@@ -60,7 +60,7 @@
|
||||
<p class="font-semibold text-sm">Workspace ID</p>
|
||||
<div class="flex flex-row gap-0.5 items-center">
|
||||
<p class="text-sm text-secondary">{$workspaceStore ?? ''}</p>
|
||||
{#if !isCloudHosted()}
|
||||
{#if !isCloudHosted() || $superadmin}
|
||||
<Button
|
||||
on:click={() => {
|
||||
open = true
|
||||
|
||||
Reference in New Issue
Block a user