Is admin
IsAdmin
Bases: MyState
is_admin = False
class-attribute
instance-attribute
on_load()
async
protect(func)
classmethod
render_admin_only(component, non_admin_component=None)
Show contents only if logged-in user is an admin.
Note: This does not protect content from being sent to client. ONLY prevents rendering.
- Use
IsAdmin.protectdecorator on event-handlers to protect server-side actions. - Use protected event handlers that set vars that contain sensitive data.
- Trigger in
on_loadof page - Or, set a private var (e.g. in
on_loaddependent on IsAdmin), and use the private var to protect computed/cached vars
- Trigger in