From ab3574575157dbcc7377a344839a8b2c221ed26d Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Wed, 14 Apr 2021 18:42:57 +0300 Subject: [WIP] Let user know their fingerprint --- src/handlers.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/handlers.rs') diff --git a/src/handlers.rs b/src/handlers.rs index cc4c6c3..3cea02c 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -152,7 +152,7 @@ pub async fn authenticate_user( return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); } - let fingerprint = Sha256::digest(&request.public_key.as_bytes()); + let fingerprint = format!(Sha256::digest(&request.public_key.as_bytes())); let new_user = User { user_id: privileged_student_id, @@ -166,11 +166,14 @@ pub async fn authenticate_user( let mut userlist = RwLockUpgradableReadGuard::upgrade(userlist); - userlist.insert(format!("{:x}", fingerprint), new_user); + userlist.insert(fingerprint, new_user); let res_json = warp::reply::json(&GradeCoinResponse { res: ResponseType::Success, - message: "User authenticated to use Gradecoin".to_owned(), + message: format!( + "User authenticated to use Gradecoin with identifier {}", + fingerprint + ), }); Ok(warp::reply::with_status(res_json, StatusCode::CREATED)) -- cgit v1.2.3-70-g09d2