Use require_admin decorator for check_config permissions (#98028)
parent
f6273bfca5
commit
50ef674902
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue