aboutsummaryrefslogtreecommitdiffstats
path: root/src/handlers.rs
diff options
context:
space:
mode:
authorYigit Sever2021-04-20 00:43:21 +0300
committerYigit Sever2021-04-20 00:43:21 +0300
commita53ccc6f5ca64d46abb94ae743dc5d063a87959e (patch)
tree75feb35db75b627d6e7e1a333b22094b58fca780 /src/handlers.rs
parent10afcb0b0ea8794b5b14acedba48bf291b164e41 (diff)
downloadgradecoin-a53ccc6f5ca64d46abb94ae743dc5d063a87959e.tar.gz
gradecoin-a53ccc6f5ca64d46abb94ae743dc5d063a87959e.tar.bz2
gradecoin-a53ccc6f5ca64d46abb94ae743dc5d063a87959e.zip
Bugfix
Users cannot authenticate twice now
Diffstat (limited to 'src/handlers.rs')
-rw-r--r--src/handlers.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/handlers.rs b/src/handlers.rs
index e12d83e..6305560 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -229,8 +229,6 @@ pub async fn authenticate_user(
229 } 229 }
230 }; 230 };
231 231
232 let provided_id = request.student_id.clone();
233
234 let privileged_student_id = match MetuId::new(request.student_id, request.passwd) { 232 let privileged_student_id = match MetuId::new(request.student_id, request.passwd) {
235 Some(id) => id, 233 Some(id) => id,
236 None => { 234 None => {
@@ -243,18 +241,20 @@ pub async fn authenticate_user(
243 } 241 }
244 }; 242 };
245 243
244 // Students should be able to authenticate once
246 { 245 {
247 let userlist = db.users.read(); 246 let userlist = db.users.read();
248 247
249 if userlist.contains_key(&provided_id) { 248 for (_, user) in userlist.iter() {
250 let res_json = warp::reply::json(&GradeCoinResponse { 249 if user.user_id == privileged_student_id {
250 let res_json = warp::reply::json(&GradeCoinResponse {
251 res: ResponseType::Error, 251 res: ResponseType::Error,
252 message: 252 message:
253 "This user is already authenticated, do you think this is a mistake? Contact me" 253 "This user is already authenticated, do you think this is a mistake? Contact me"
254 .to_owned(), 254 .to_owned(),
255 }); 255 });
256 256 return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST));
257 return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); 257 }
258 } 258 }
259 } 259 }
260 260