Skip to content

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.protect decorator on event-handlers to protect server-side actions.
  • Use protected event handlers that set vars that contain sensitive data.
    • Trigger in on_load of page
    • Or, set a private var (e.g. in on_load dependent on IsAdmin), and use the private var to protect computed/cached vars