aboutsummaryrefslogtreecommitdiffstats
path: root/src/student.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/student.rs')
-rw-r--r--src/student.rs70
1 files changed, 10 insertions, 60 deletions
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 @@
1use crate::Fingerprint; 1use crate::{Fingerprint, Id};
2use lazy_static::lazy_static;
3use serde::{Deserialize, Serialize}; 2use serde::{Deserialize, Serialize};
4use std::{collections::HashSet, fmt}; 3use std::fmt;
5 4
6#[derive(Debug, Serialize, Deserialize, PartialEq)] 5#[derive(Debug, Serialize, Deserialize, PartialEq)]
7pub struct UserAtRest { 6pub struct UserAtRest {
@@ -25,11 +24,9 @@ pub struct User {
25 pub is_bot: bool, 24 pub is_bot: bool,
26} 25}
27 26
28/// The values are hard coded in [`static@OUR_STUDENTS`] so `MetuId::new`() can accept/reject values based on that
29/// TODO update the statement above
30#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] 27#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
31pub struct MetuId { 28pub struct MetuId {
32 id: String, 29 id: Id,
33 passwd: String, 30 passwd: String,
34} 31}
35 32
@@ -40,62 +37,15 @@ impl fmt::Display for MetuId {
40} 37}
41 38
42impl MetuId { 39impl MetuId {
43 pub fn new(id: String, pwd: String) -> Option<Self> { 40 pub fn new(id: String, passwd: String) -> Self {
44 if OUR_STUDENTS.contains(&(&*id, &*pwd)) { 41 MetuId { id, passwd }
45 Some(MetuId { id, passwd: pwd })
46 } else {
47 None
48 }
49 } 42 }
50 43
51 // TODO: replace the function above with this <15-04-22, yigit> // 44 pub fn get_id(&self) -> &Id {
52 pub fn _new(id: String, passwd: String) -> Self { 45 &self.id
53 MetuId { id, passwd }
54 } 46 }
55}
56 47
57// TODO: remove this, read from a yaml or something, then MetuId::new gets a self <11-04-22, yigit> // 48 pub fn get_passwd(&self) -> &String {
58// Students who are authorized to have Gradecoin accounts 49 &self.passwd
59lazy_static! { 50 }
60 static ref OUR_STUDENTS: HashSet<(&'static str, &'static str)> = {
61 [
62 ("e254275", "DtNX1qk4YF4saRH"),
63 ("e223687", "cvFEs4XLjuGBD1v"),
64 ("e211024", "voQAcxiKJmEXYRT"),
65 ("e209888", "O75dli6AQtz2tUi"),
66 ("e223725", "xXuTD3Y4tyrv2Jz"),
67 ("e209362", "N7wGm5XU5zVWOWu"),
68 ("e209898", "aKBFfB8fZMq8pVn"),
69 ("e230995", "TgcHGlqeFhQGx42"),
70 ("e223743", "YVWVSWuIHplJk9C"),
71 ("e223747", "8LAeHrsjnwXh59Q"),
72 ("e223749", "HMFeJqVOzwCPHbc"),
73 ("e223751", "NjMsxmtmy2VOwMW"),
74 ("e188126", "QibuPdV2gXfsVJW"),
75 ("e209913", "kMxJvl2vHSWCy4A"),
76 ("e203608", "mfkkR0MWurk6Rp1"),
77 ("e233013", "GCqHxdOaDj2pWXx"),
78 ("e216982", "2Z0xmgCStnj5qg5"),
79 ("e217185", "BcaZNlzlhPph7A3"),
80 ("e223780", "2KvVxKUQaA9H4sn"),
81 ("e194931", "hsC0Wb8PQ5vzwdQ"),
82 ("e223783", "ETUJA3kt1QYvJai"),
83 ("e254550", "rPRjX0A4NefvKWi"),
84 ("e217203", "lN3IWhGyCrGfkk5"),
85 ("e217477", "O9xlMaa7LanC82w"),
86 ("e223786", "UxI6czykJfp9T9N"),
87 ("e231060", "VJgziofQQPCoisH"),
88 ("e223795", "pmcTCKox99NFsqp"),
89 ("e223715", "1H5QuOYI1b2r9ET"),
90 ("e181932", "THANKYOUHAVEFUN"),
91 ("bank", "P7oxDm30g1jeIId"),
92 ("friend_1", "not_used"),
93 ("friend_2", "not_used"),
94 ("friend_3", "not_used"),
95 ("friend_4", "not_used"),
96 ]
97 .iter()
98 .copied()
99 .collect()
100 };
101} 51}