Improve error handling.
This commit is contained in:
parent
9ac8dac95b
commit
204233b663
|
@ -0,0 +1,2 @@
|
||||||
|
{{#> layout }}
|
||||||
|
{{/layout}}
|
|
@ -442,7 +442,7 @@ fn by_keyid(db: rocket::State<Polymorphic>, domain: rocket::State<Domain>,
|
||||||
#[get("/vks/v1/verify/<token>")]
|
#[get("/vks/v1/verify/<token>")]
|
||||||
fn verify(
|
fn verify(
|
||||||
db: rocket::State<Polymorphic>, domain: rocket::State<Domain>, token: String,
|
db: rocket::State<Polymorphic>, domain: rocket::State<Domain>, token: String,
|
||||||
) -> result::Result<Template, Custom<String>> {
|
) -> MyResponse {
|
||||||
match db.verify_token(&token) {
|
match db.verify_token(&token) {
|
||||||
Ok(Some((userid, fpr))) => {
|
Ok(Some((userid, fpr))) => {
|
||||||
let context = templates::Verify {
|
let context = templates::Verify {
|
||||||
|
@ -454,20 +454,10 @@ fn verify(
|
||||||
commit: env!("VERGEN_SHA_SHORT").to_string(),
|
commit: env!("VERGEN_SHA_SHORT").to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Template::render("verify", context))
|
MyResponse::ok("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))
|
|
||||||
}
|
}
|
||||||
|
Ok(None) => MyResponse::not_found(Some("generic-error"), None),
|
||||||
|
Err(e) => MyResponse::ise(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue