diff options
author | Yigit Sever | 2021-04-14 18:42:57 +0300 |
---|---|---|
committer | Yigit Sever | 2021-04-14 19:12:51 +0300 |
commit | ab3574575157dbcc7377a344839a8b2c221ed26d (patch) | |
tree | 13616c5093cfaa2619a8c5f739425834c265dc1c | |
parent | 99f9c5f918a6a9946015cf0e9f2e0054e28b3ab0 (diff) | |
download | gradecoin-ab3574575157dbcc7377a344839a8b2c221ed26d.tar.gz gradecoin-ab3574575157dbcc7377a344839a8b2c221ed26d.tar.bz2 gradecoin-ab3574575157dbcc7377a344839a8b2c221ed26d.zip |
[WIP] Let user know their fingerprint
-rw-r--r-- | src/handlers.rs | 9 |
1 files changed, 6 insertions, 3 deletions
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( | |||
152 | return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); | 152 | return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); |
153 | } | 153 | } |
154 | 154 | ||
155 | let fingerprint = Sha256::digest(&request.public_key.as_bytes()); | 155 | let fingerprint = format!(Sha256::digest(&request.public_key.as_bytes())); |
156 | 156 | ||
157 | let new_user = User { | 157 | let new_user = User { |
158 | user_id: privileged_student_id, | 158 | user_id: privileged_student_id, |
@@ -166,11 +166,14 @@ pub async fn authenticate_user( | |||
166 | 166 | ||
167 | let mut userlist = RwLockUpgradableReadGuard::upgrade(userlist); | 167 | let mut userlist = RwLockUpgradableReadGuard::upgrade(userlist); |
168 | 168 | ||
169 | userlist.insert(format!("{:x}", fingerprint), new_user); | 169 | userlist.insert(fingerprint, new_user); |
170 | 170 | ||
171 | let res_json = warp::reply::json(&GradeCoinResponse { | 171 | let res_json = warp::reply::json(&GradeCoinResponse { |
172 | res: ResponseType::Success, | 172 | res: ResponseType::Success, |
173 | message: "User authenticated to use Gradecoin".to_owned(), | 173 | message: format!( |
174 | "User authenticated to use Gradecoin with identifier {}", | ||
175 | fingerprint | ||
176 | ), | ||
174 | }); | 177 | }); |
175 | 178 | ||
176 | Ok(warp::reply::with_status(res_json, StatusCode::CREATED)) | 179 | Ok(warp::reply::with_status(res_json, StatusCode::CREATED)) |