diff options
author | Yigit Sever | 2021-04-18 20:04:07 +0300 |
---|---|---|
committer | Yigit Sever | 2021-04-18 20:04:07 +0300 |
commit | 5f066ada307881e08e61ee9a94a9fc65440bc64f (patch) | |
tree | af0601c30eda3f93de2e74fef29f78726bffa329 /src | |
parent | 11dbf57a531dbb17ea5f25cc7c3616a3e4ebedcf (diff) | |
download | gradecoin-5f066ada307881e08e61ee9a94a9fc65440bc64f.tar.gz gradecoin-5f066ada307881e08e61ee9a94a9fc65440bc64f.tar.bz2 gradecoin-5f066ada307881e08e61ee9a94a9fc65440bc64f.zip |
Verbose JWT error message in transactions
Diffstat (limited to 'src')
-rw-r--r-- | src/handlers.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/handlers.rs b/src/handlers.rs index ddcc8a3..ead6828 100644 --- a/src/handlers.rs +++ b/src/handlers.rs | |||
@@ -527,7 +527,7 @@ pub async fn propose_transaction( | |||
527 | token: String, | 527 | token: String, |
528 | db: Db, | 528 | db: Db, |
529 | ) -> Result<impl warp::Reply, warp::Rejection> { | 529 | ) -> Result<impl warp::Reply, warp::Rejection> { |
530 | debug!("POST /transaction, authorized_propose_transaction() is handling"); | 530 | debug!("POST /transaction, propose_transaction() is handling"); |
531 | 531 | ||
532 | let users_store = db.users.read(); | 532 | let users_store = db.users.read(); |
533 | 533 | ||
@@ -659,10 +659,11 @@ pub async fn propose_transaction( | |||
659 | let hashed_transaction = | 659 | let hashed_transaction = |
660 | Md5::digest((&serde_json::to_string(&new_transaction).unwrap()).as_ref()); | 660 | Md5::digest((&serde_json::to_string(&new_transaction).unwrap()).as_ref()); |
661 | if token_payload.claims.tha != format!("{:x}", hashed_transaction) { | 661 | if token_payload.claims.tha != format!("{:x}", hashed_transaction) { |
662 | debug!("The hash of the transaction did not match with the hash given in JWT"); | ||
662 | return Ok(warp::reply::with_status( | 663 | return Ok(warp::reply::with_status( |
663 | warp::reply::json(&GradeCoinResponse { | 664 | warp::reply::json(&GradeCoinResponse { |
664 | res: ResponseType::Error, | 665 | res: ResponseType::Error, |
665 | message: "The hash of the block did not match the hash given in JWT".to_owned(), | 666 | message: "The hash of the transaction did not match the hash given in JWT".to_owned(), |
666 | }), | 667 | }), |
667 | StatusCode::BAD_REQUEST, | 668 | StatusCode::BAD_REQUEST, |
668 | )); | 669 | )); |