♻️ (user): Usa el panel y el acceso del núcleo
pagetop-user deja de depender de pagetop-admin: declara sus páginas en el panel del núcleo y monta sus rutas con su acceso. Quita las comprobaciones que repetían el permiso de la ruta y, con la acción AnonymousDenied, ofrece el inicio de sesión a un usuario anónimo sin acceso, también en las peticiones HTMX.
This commit is contained in:
parent
824dc4a3ab
commit
9ba493c2c4
19 changed files with 343 additions and 501 deletions
|
|
@ -197,6 +197,7 @@ async fn account_flows() {
|
|||
password_resets_are_limited_by_account(&client).await;
|
||||
requests_are_limited_by_address(&client).await;
|
||||
failed_logins_are_limited_by_address(&client).await;
|
||||
anonymous_visitors_are_offered_to_sign_in(&client).await;
|
||||
}
|
||||
|
||||
async fn registration_requires_confirming_the_address(client: &Client) {
|
||||
|
|
@ -797,3 +798,34 @@ async fn failed_logins_are_limited_by_address(client: &Client) {
|
|||
.await;
|
||||
assert_eq!(reply.status, Status::SEE_OTHER);
|
||||
}
|
||||
|
||||
// A route that needs a session or a permission sends an anonymous visitor to the login form, which
|
||||
// returns to that route afterwards. An HTMX request gets the same login as a full-page redirect,
|
||||
// returning to the page open in the browser, instead of the form inside the fragment it expected.
|
||||
async fn anonymous_visitors_are_offered_to_sign_in(client: &Client) {
|
||||
let reply = client.get("/user/edit?tab=1", None).await;
|
||||
assert_eq!(reply.status, Status::SEE_OTHER);
|
||||
assert_eq!(
|
||||
reply.location(),
|
||||
"/user/login?waypoint=%2Fuser%2Fedit%3Ftab%3D1"
|
||||
);
|
||||
// A public profile checks its permission in the handler, with the same answer.
|
||||
let reply = client.get("/user/1", None).await;
|
||||
assert_eq!(reply.status, Status::SEE_OTHER);
|
||||
assert_eq!(reply.location(), "/user/login?waypoint=%2Fuser%2F1");
|
||||
|
||||
let request = web::test::TestRequest::get()
|
||||
.uri("/admin/user/users?page=2")
|
||||
.header("hx-request", "true")
|
||||
.header(
|
||||
"hx-current-url",
|
||||
"http://localhost:8080/admin/user/users?sort=name",
|
||||
);
|
||||
let reply = client.send(request).await;
|
||||
assert_eq!(reply.status, Status::OK);
|
||||
assert!(reply.body.is_empty(), "{}", reply.body);
|
||||
assert_eq!(
|
||||
reply.header("hx-redirect"),
|
||||
"/user/login?waypoint=%2Fadmin%2Fuser%2Fusers%3Fsort%3Dname"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue