mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-07-08 18:06:29 +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.
|
||||
|
||||
```python
|
||||
from homeassistant.exceptions import Unauthorized, UnknownUser
|
||||
from homeassistant.helpers import service
|
||||
|
||||
# New in Home Assistant 0.90
|
||||
@service.require_admin
|
||||
async def handle_admin_service(call):
|
||||
"""Handle a service call."""
|
||||
# Do admin action
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
hass.services.async_register(DOMAIN, 'my_service',
|
||||
handle_admin_service(hass))
|
||||
hass.helpers.service.async_register_admin_service(
|
||||
DOMAIN, 'my_service', handle_admin_service, vol.Schema({})
|
||||
)
|
||||
return True
|
||||
```
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user