✨ (auth): Añade permisos tipados
Sustituye las claves de permiso `&str` sueltas por el trait `Permission` (clave, etiqueta y grupo), y añade `require_permission()` para cortar un handler con `ErrorPage::AccessDenied` antes de construir nada. Para que `require_permission()` pueda fallar sin un `Context` previo, `ErrorPage` pasa a envolver `Option<HttpRequest>`, `Context::new()` recibe ahora `HttpRequest` sin `Option`, y se añade `Context::admin()` para la plantilla de administración.
This commit is contained in:
parent
ea0dc021ce
commit
747e64ce34
10 changed files with 297 additions and 120 deletions
|
|
@ -46,10 +46,10 @@ impl Theme for MarkerTheme {
|
|||
|
||||
#[pagetop::test]
|
||||
async fn default_template_identity_is_independent_of_theme() {
|
||||
let cx = Context::new(None);
|
||||
let cx = Context::default();
|
||||
assert_eq!(cx.template().name(), "standard");
|
||||
|
||||
let cx = Context::new(None).with_theme(&MarkerTheme);
|
||||
let cx = Context::default().with_theme(&MarkerTheme);
|
||||
assert_eq!(cx.template().name(), "standard");
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ async fn admin_template_identity_is_independent_of_theme() {
|
|||
async fn explicit_template_is_not_overridden_by_a_later_with_theme() {
|
||||
// A template explicitly set with `with_template()` prevails even if `with_theme()` is called
|
||||
// afterwards.
|
||||
let cx = Context::new(None)
|
||||
let cx = Context::default()
|
||||
.with_template(&CoreTemplate::Admin)
|
||||
.with_theme(&pagetop::base::theme::Basic);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue