chore: fix struct definition

This commit is contained in:
Jesús Pérez Lorenzo 2021-10-19 20:58:19 +01:00
parent b7df108967
commit de2cce474c
2 changed files with 23 additions and 0 deletions

View file

@ -21,6 +21,7 @@ use app_env::{
use app_tools::{hash_from_data,read_path_file};
use app_auth::{
AuthStore,
User,
UserCtx,
BEARER_PREFIX,
AuthError,
@ -391,6 +392,23 @@ impl ReqTasks {
role = String::from("");
}
role
}
#[allow(clippy::missing_errors_doc)]
pub async fn get_user(&self) -> User {
let token = self.token_from_header().unwrap_or_else(|e| {
if envmnt::get_isize("DEBUG", 0) > 0 {
println!("{}",e);
}
String::from("")
});
if !token.is_empty() {
if let Some(user_id) = self.auth_store.sessions.read().await.get(&token) {
if let Some(user) = self.auth_store.users.read().await.get(user_id) {
return user.to_owned()
}
}
}
User::default()
}
#[allow(clippy::missing_errors_doc)]
pub async fn check_authentication(&self, token: String) -> anyhow::Result<UserCtx> {