aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYigit Sever2021-04-18 20:04:07 +0300
committerYigit Sever2021-04-18 20:04:07 +0300
commita9dbfe9a2a11f9614e9618d8d2895eb1ca33db7f (patch)
tree7070c6ea3307cc9630f65192f875841a8136eb03 /src
parent25f65a7c3c85325ddd5e02281cfb936677943eb0 (diff)
downloadgradecoin-a9dbfe9a2a11f9614e9618d8d2895eb1ca33db7f.tar.gz
gradecoin-a9dbfe9a2a11f9614e9618d8d2895eb1ca33db7f.tar.bz2
gradecoin-a9dbfe9a2a11f9614e9618d8d2895eb1ca33db7f.zip
Verbose JWT error message in transactions
Diffstat (limited to 'src')
-rw-r--r--src/handlers.rs5
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 ));