Admin configuration
Enable and configure the admin panel.
● ● ●
RuniqueAppBuilder::new(config)
.with_public_url("https://mysite.com") // reset links sent from the admin
.with_admin(|a| {
a.site_title("My Administration")
.routes(admins::routes("/admin"))
// Custom dashboard (optional)
.templates(|t| t.with_dashboard("admin/my_dashboard.html"))
.with_state(admins::admin_state())
})
// The admin signs in eihwaz_users accounts — there is no separate
// admin user model and nothing to implement.
//
// Sign-in: password checked first (same timing for any username),
// then the account must be active and is_staff or is_superuser.
let user = authenticate_admin(&db, &username, &password).await; // Option<Model>
// What a staff member may do on each resource comes from their groups
// (eihwaz_groupes / eihwaz_groupes_droits), read from the database on
// every request: removing a right takes effect immediately.
// A superuser passes every check.
// For each resource declared in admin!:
GET /admin/ -> dashboard
GET /admin/article/list -> list
GET /admin/article/create -> create form
POST /admin/article/create -> create handler
GET /admin/article/{id}/detail -> detail
GET /admin/article/{id}/edit -> edit form
POST /admin/article/{id}/edit -> edit handler
POST /admin/article/{id}/delete -> delete
POST /admin/article/bulk -> group actions
// Every write goes through the same gate: right on the resource,
// rows the account may touch, fields of the form only.