handling case where keyfile lock contains value of none

This commit is contained in:
realisation 2023-10-23 12:23:56 -04:00
parent 283c900a76
commit 584d5e958c

View File

@ -106,7 +106,13 @@ pub async fn register(
}
async fn handle_has_keyfile(keyfile: Arc<Mutex<Option<Vec<u8>>>>) -> Result<impl Reply, Rejection> {
let keyfile_lock = keyfile.lock().unwrap();
if keyfile_lock.is_none() {
return Ok(warp::reply::json(&"".to_string()))
}
let encoded_keyfile = keyfile_lock.as_ref().unwrap();
let username: String = match encoded_keyfile.is_empty() {
true => "".to_string(),
@ -116,7 +122,9 @@ async fn handle_has_keyfile(keyfile: Arc<Mutex<Option<Vec<u8>>>>) -> Result<impl
}
};
Ok(warp::reply::json(&username))
Ok(warp::reply::json(
&username
))
}
async fn handle_keyfile_vet(
@ -180,6 +188,7 @@ async fn handle_boot(
jwt_secret_bytes: jwt_secret.to_vec(),
file_key: keygen::generate_file_key(),
}
} else {
match keygen::decode_keyfile(encoded_keyfile.clone(), &info.password) {
Ok(k) => k,