summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/handlers.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/handlers.rs b/src/handlers.rs
index 5e957bb..cc4c6c3 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -12,7 +12,7 @@ use parking_lot::RwLockUpgradableReadGuard;
12use rsa::{PaddingScheme, RSAPrivateKey}; 12use rsa::{PaddingScheme, RSAPrivateKey};
13use serde::Serialize; 13use serde::Serialize;
14use serde_json; 14use serde_json;
15use sha2; 15use sha2::Sha256;
16use std::convert::Infallible; 16use std::convert::Infallible;
17use std::fs; 17use std::fs;
18use warp::{http::StatusCode, reply}; 18use warp::{http::StatusCode, reply};
@@ -152,6 +152,8 @@ 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());
156
155 let new_user = User { 157 let new_user = User {
156 user_id: privileged_student_id, 158 user_id: privileged_student_id,
157 public_key: request.public_key, 159 public_key: request.public_key,
@@ -163,8 +165,8 @@ pub async fn authenticate_user(
163 fs::write(format!("users/{}.guy", new_user.user_id), user_json).unwrap(); 165 fs::write(format!("users/{}.guy", new_user.user_id), user_json).unwrap();
164 166
165 let mut userlist = RwLockUpgradableReadGuard::upgrade(userlist); 167 let mut userlist = RwLockUpgradableReadGuard::upgrade(userlist);
166 userlist.insert(provided_id, new_user); 168
167 // TODO: signature of the public key, please <11-04-21, yigit> // 169 userlist.insert(format!("{:x}", fingerprint), new_user);
168 170
169 let res_json = warp::reply::json(&GradeCoinResponse { 171 let res_json = warp::reply::json(&GradeCoinResponse {
170 res: ResponseType::Success, 172 res: ResponseType::Success,