Skip to content

Commit

Permalink
readme + logs
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaCoduriV committed Jan 27, 2023
1 parent fa646d1 commit 3fcd644
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 0 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

- Error management: The original code did not handle errors in a consistent or secure manner, often panicking and revealing sensitive information. I added proper error handling and ensured that any errors that occur do not reveal sensitive information.

- Input/output validation: The original code did not validate user input, making it vulnerable to various types of attacks such as SQL injection. I added input validation to ensure that only valid input is accepted, and output validation to ensure that any sensitive information is displayed only to authorized users.

2. High-level report:
- Implemented a login system for both students and teachers, with proper authentication and authorization.

Expand Down
8 changes: 6 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ fn teacher_action(username: &str) -> Result<(), ()> {
match choice {
1 => {
let student_username: String = input().msg("Enter the name of the user of which you want to see the grades:").get();
info!("{} showing {}'s grades", username, student_username);
return Ok(show_grades(student_username.as_str()));
}
2 => Ok(enter_grade(username)),
Expand All @@ -119,7 +120,10 @@ fn show_grades(username: &str) {
(student.grades.iter().sum::<f32>()) / ((*student.grades).len() as f32)
);
}
None => println!("User not in system"),
None => {
println!("User not in system");
warn!("user {} not in system", username);
},
};
}

Expand All @@ -131,7 +135,7 @@ fn enter_grade(username: &str) {
let mut map = DB_INSTANCE.students.lock().unwrap();
match map.get_mut(&name) {
Some(v) => {
info!("{} added {} to {}'s grades.", username, grade, name);
info!("{} added a grade to {}'s grades.", username, name);
v.grades.push(grade)
},
None => {
Expand Down

0 comments on commit 3fcd644

Please sign in to comment.