Use require_admin decorator for check_config permissions (#98028)

pull/98048/head
Franck Nijhof 2023-08-08 12:19:20 +02:00 committed by GitHub
parent f6273bfca5
commit 50ef674902
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 5 deletions

View File

@ -5,11 +5,10 @@ from typing import Any
import voluptuous as vol
from homeassistant.components import websocket_api
from homeassistant.components.http import HomeAssistantView
from homeassistant.components.http import HomeAssistantView, require_admin
from homeassistant.components.sensor import async_update_suggested_units
from homeassistant.config import async_check_ha_config_file
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import Unauthorized
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.util import location, unit_system
@ -29,11 +28,9 @@ class CheckConfigView(HomeAssistantView):
url = "/api/config/core/check_config"
name = "api:config:core:check_config"
@require_admin
async def post(self, request):
"""Validate configuration and return results."""
if not request["hass_user"].is_admin:
raise Unauthorized()
errors = await async_check_ha_config_file(request.app["hass"])
state = "invalid" if errors else "valid"