aboutsummaryrefslogtreecommitdiffstats
path: root/src/handlers.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/handlers.rs')
-rw-r--r--src/handlers.rs36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/handlers.rs b/src/handlers.rs
index 96001ce..ca0608c 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -220,7 +220,7 @@ pub async fn authenticate_user(
220 }; 220 };
221 221
222 // c field was properly base64 encoded, now available in auth_packet 222 // c field was properly base64 encoded, now available in auth_packet
223 // decryptor was setup properly, with the correct lenght key 223 // decryptor was setup properly, with the correct length key
224 let mut buf = auth_packet; 224 let mut buf = auth_packet;
225 let auth_plaintext = match cipher.decrypt(&mut buf) { 225 let auth_plaintext = match cipher.decrypt(&mut buf) {
226 Ok(p) => p, 226 Ok(p) => p,
@@ -278,24 +278,22 @@ pub async fn authenticate_user(
278 }; 278 };
279 279
280 // is the student in AuthRequest privileged? 280 // is the student in AuthRequest privileged?
281 // TODO: this is the only check for 'if metuid is approved' <15-04-22, yigit> // 281 let privileged_student_id = if db.is_user_preapproved(&request.student_id, &request.passwd) {
282 let privileged_student_id = 282 MetuId::new(request.student_id.clone(), request.passwd.clone())
283 if let Some(id) = MetuId::new(request.student_id.clone(), request.passwd.clone()) { 283 } else {
284 id 284 debug!(
285 } else { 285 "Someone tried to auth with invalid credentials: {} {}",
286 debug!( 286 &request.student_id, &request.passwd
287 "Someone tried to auth with invalid credentials: {} {}", 287 );
288 &request.student_id, &request.passwd 288 let res_json = warp::reply::json(&GradeCoinResponse {
289 ); 289 res: ResponseType::Error,
290 let res_json = warp::reply::json(&GradeCoinResponse { 290 message:
291 res: ResponseType::Error, 291 "The credentials given ('student_id', 'passwd') cannot hold a Gradecoin account"
292 message: 292 .to_owned(),
293 "The credentials given ('student_id', 'passwd') cannot hold a Gradecoin account" 293 });
294 .to_owned(),
295 });
296 294
297 return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); 295 return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST));
298 }; 296 };
299 297
300 // Students should be able to authenticate once 298 // Students should be able to authenticate once
301 { 299 {
@@ -382,7 +380,7 @@ pub async fn list_transactions(db: Db) -> Result<impl warp::Reply, Infallible> {
382/// Proposes a new block for the next round. 380/// Proposes a new block for the next round.
383/// Can reject the block 381/// Can reject the block
384/// 382///
385/// The proposer has to put their transaction as the first transaction of the transaction_list. 383/// The proposer has to put their transaction as the first transaction of the `Block::transaction_list`.
386/// This is the analogue of `coinbase` in Bitcoin works 384/// This is the analogue of `coinbase` in Bitcoin works
387/// 385///
388/// The `coinbase` transaction also gets something for their efforts. 386/// The `coinbase` transaction also gets something for their efforts.