mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-07-09 10:26:30 +00:00
Update auth_permissions.md (#197)
This commit is contained in:
parent
3d955997a1
commit
f3c7e43baf
@ -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
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user