feat: enforce custom appearance policy
This commit is contained in:
@@ -1013,7 +1013,8 @@ def update_profile(
|
||||
next_settings["ui"] = UserUiPreferences().model_dump()
|
||||
else:
|
||||
appearance = _effective_appearance_info(session, tenant=context.tenant, user=context.user)
|
||||
stored_palette = _user_ui_preferences(context.user.settings).palette
|
||||
stored_preferences = _user_ui_preferences(context.user.settings)
|
||||
stored_palette = stored_preferences.palette
|
||||
if (
|
||||
appearance.locked
|
||||
and payload.ui_preferences.palette is not None
|
||||
@@ -1023,6 +1024,17 @@ def update_profile(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="The effective appearance policy locks the palette.",
|
||||
)
|
||||
requested_overrides = payload.ui_preferences.appearance_overrides
|
||||
if (
|
||||
"appearance_overrides" in payload.ui_preferences.model_fields_set
|
||||
and not appearance.custom_overrides_allowed
|
||||
and requested_overrides is not None
|
||||
and requested_overrides != stored_preferences.appearance_overrides
|
||||
):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="The effective appearance policy does not allow personal custom overrides.",
|
||||
)
|
||||
if (
|
||||
payload.ui_preferences.navigation is not None
|
||||
and payload.ui_preferences.navigation.locked
|
||||
|
||||
Reference in New Issue
Block a user