This commit is contained in:
Andras Schmelczer 2024-12-08 18:14:14 +00:00
parent e1ba3d44c7
commit dda356ea00
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
8 changed files with 60 additions and 0 deletions

View file

@ -0,0 +1,14 @@
use crate::{
app_state::AppState,
config::user_config::User,
errors::{unauthorized_error, SyncServerError},
};
pub fn auth(app_state: &AppState, token: &str) -> Result<User, SyncServerError> {
app_state
.config
.users
.get_user(token)
.cloned()
.ok_or_else(|| unauthorized_error(anyhow::anyhow!("Invalid token")))
}