returning empty string or username on has keyfile. updated register submodule commit

This commit is contained in:
realisation 2023-10-23 11:16:42 -04:00
parent aa2839cdec
commit 319e30a0c6
2 changed files with 13 additions and 2 deletions

@ -1 +1 @@
Subproject commit a4a66d61fd31605148d9e1dc0498a0540188fd66
Subproject commit f51aa927c842e13ed3b80fc7de1976477f869601

View File

@ -106,8 +106,19 @@ 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();
let encoded_keyfile = keyfile_lock.as_ref().unwrap();
let username: String = match encoded_keyfile.is_empty() {
true => "".to_string(),
false => {
let (user, ..): (String,) = bincode::deserialize(encoded_keyfile).unwrap();
user
}
};
Ok(warp::reply::json(
&keyfile.lock().unwrap().as_ref().unwrap().is_empty(),
&username
))
}