Fixes suggested by clippy

This commit is contained in:
SinTan1729
2023-04-26 14:40:54 -05:00
parent 2c34598faf
commit ff4801a476
4 changed files with 16 additions and 31 deletions

View File

@@ -8,21 +8,12 @@ pub fn validate(session: Session) -> bool {
}
let token = session.get::<String>("session-token");
if token.is_err() {
false
} else if !check(token.unwrap()) {
false
} else {
true
}
token.is_ok() && check(token.unwrap())
}
fn check(token: Option<String>) -> bool {
if token.is_none() {
false
} else {
let token_body = token.unwrap();
let token_parts: Vec<&str> = token_body.split(";").collect();
if let Some(token_body) = token {
let token_parts: Vec<&str> = token_body.split(';').collect();
if token_parts.len() < 2 {
false
} else {
@@ -32,13 +23,10 @@ fn check(token: Option<String>) -> bool {
.duration_since(SystemTime::UNIX_EPOCH)
.expect("Time went backwards!")
.as_secs();
if token_text == "session-token" && time_now < token_time + 1209600 {
// There are 1209600 seconds in 14 days
true
} else {
false
}
token_text == "session-token" && time_now < token_time + 1209600 // There are 1209600 seconds in 14 days
}
} else {
false
}
}