Update auth_permissions.md (#197)

This commit is contained in:
Paulus Schoutsen 2019-03-12 22:09:59 -07:00 committed by GitHub
parent 3d955997a1
commit f3c7e43baf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -203,19 +203,16 @@ Starting Home Assistant 0.90, there is a special decorator to help protect
services that require admin access. services that require admin access.
```python ```python
from homeassistant.exceptions import Unauthorized, UnknownUser
from homeassistant.helpers import service
# New in Home Assistant 0.90 # New in Home Assistant 0.90
@service.require_admin
async def handle_admin_service(call): async def handle_admin_service(call):
"""Handle a service call.""" """Handle a service call."""
# Do admin action # Do admin action
async def async_setup(hass, config): async def async_setup(hass, config):
hass.services.async_register(DOMAIN, 'my_service', hass.helpers.service.async_register_admin_service(
handle_admin_service(hass)) DOMAIN, 'my_service', handle_admin_service, vol.Schema({})
)
return True return True
``` ```