From 3224b9fdd9174e51eb3e9842ce5abccf735abdfd Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Sat, 16 Apr 2022 18:06:37 +0300 Subject: final touches for 2022 spring --- src/student.rs | 70 +++++++++------------------------------------------------- 1 file changed, 10 insertions(+), 60 deletions(-) (limited to 'src/student.rs') diff --git a/src/student.rs b/src/student.rs index 711eeeb..2b9c5bd 100644 --- a/src/student.rs +++ b/src/student.rs @@ -1,7 +1,6 @@ -use crate::Fingerprint; -use lazy_static::lazy_static; +use crate::{Fingerprint, Id}; use serde::{Deserialize, Serialize}; -use std::{collections::HashSet, fmt}; +use std::fmt; #[derive(Debug, Serialize, Deserialize, PartialEq)] pub struct UserAtRest { @@ -25,11 +24,9 @@ pub struct User { pub is_bot: bool, } -/// The values are hard coded in [`static@OUR_STUDENTS`] so `MetuId::new`() can accept/reject values based on that -/// TODO update the statement above #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] pub struct MetuId { - id: String, + id: Id, passwd: String, } @@ -40,62 +37,15 @@ impl fmt::Display for MetuId { } impl MetuId { - pub fn new(id: String, pwd: String) -> Option { - if OUR_STUDENTS.contains(&(&*id, &*pwd)) { - Some(MetuId { id, passwd: pwd }) - } else { - None - } + pub fn new(id: String, passwd: String) -> Self { + MetuId { id, passwd } } - // TODO: replace the function above with this <15-04-22, yigit> // - pub fn _new(id: String, passwd: String) -> Self { - MetuId { id, passwd } + pub fn get_id(&self) -> &Id { + &self.id } -} -// TODO: remove this, read from a yaml or something, then MetuId::new gets a self <11-04-22, yigit> // -// Students who are authorized to have Gradecoin accounts -lazy_static! { - static ref OUR_STUDENTS: HashSet<(&'static str, &'static str)> = { - [ - ("e254275", "DtNX1qk4YF4saRH"), - ("e223687", "cvFEs4XLjuGBD1v"), - ("e211024", "voQAcxiKJmEXYRT"), - ("e209888", "O75dli6AQtz2tUi"), - ("e223725", "xXuTD3Y4tyrv2Jz"), - ("e209362", "N7wGm5XU5zVWOWu"), - ("e209898", "aKBFfB8fZMq8pVn"), - ("e230995", "TgcHGlqeFhQGx42"), - ("e223743", "YVWVSWuIHplJk9C"), - ("e223747", "8LAeHrsjnwXh59Q"), - ("e223749", "HMFeJqVOzwCPHbc"), - ("e223751", "NjMsxmtmy2VOwMW"), - ("e188126", "QibuPdV2gXfsVJW"), - ("e209913", "kMxJvl2vHSWCy4A"), - ("e203608", "mfkkR0MWurk6Rp1"), - ("e233013", "GCqHxdOaDj2pWXx"), - ("e216982", "2Z0xmgCStnj5qg5"), - ("e217185", "BcaZNlzlhPph7A3"), - ("e223780", "2KvVxKUQaA9H4sn"), - ("e194931", "hsC0Wb8PQ5vzwdQ"), - ("e223783", "ETUJA3kt1QYvJai"), - ("e254550", "rPRjX0A4NefvKWi"), - ("e217203", "lN3IWhGyCrGfkk5"), - ("e217477", "O9xlMaa7LanC82w"), - ("e223786", "UxI6czykJfp9T9N"), - ("e231060", "VJgziofQQPCoisH"), - ("e223795", "pmcTCKox99NFsqp"), - ("e223715", "1H5QuOYI1b2r9ET"), - ("e181932", "THANKYOUHAVEFUN"), - ("bank", "P7oxDm30g1jeIId"), - ("friend_1", "not_used"), - ("friend_2", "not_used"), - ("friend_3", "not_used"), - ("friend_4", "not_used"), - ] - .iter() - .copied() - .collect() - }; + pub fn get_passwd(&self) -> &String { + &self.passwd + } } -- cgit v1.2.3-70-g09d2