diff --git a/dist/templates/generic-error.html.hbs b/dist/templates/generic-error.html.hbs new file mode 100644 index 0000000..abbaa5e --- /dev/null +++ b/dist/templates/generic-error.html.hbs @@ -0,0 +1,2 @@ +{{#> layout }} +{{/layout}} diff --git a/src/web/mod.rs b/src/web/mod.rs index 9770e91..54f6d05 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -442,7 +442,7 @@ fn by_keyid(db: rocket::State, domain: rocket::State, #[get("/vks/v1/verify/")] fn verify( db: rocket::State, domain: rocket::State, token: String, -) -> result::Result> { +) -> MyResponse { match db.verify_token(&token) { Ok(Some((userid, fpr))) => { let context = templates::Verify { @@ -454,20 +454,10 @@ fn verify( commit: env!("VERGEN_SHA_SHORT").to_string(), }; - Ok(Template::render("verify", context)) - } - Ok(None) | Err(_) => { - let context = templates::Verify { - verified: false, - domain: domain.0.clone(), - userid: "".into(), - fpr: "".into(), - version: env!("VERGEN_SEMVER").to_string(), - commit: env!("VERGEN_SHA_SHORT").to_string(), - }; - - Ok(Template::render("verify", context)) + MyResponse::ok("verify", context) } + Ok(None) => MyResponse::not_found(Some("generic-error"), None), + Err(e) => MyResponse::ise(e), } }