- add: session_id to the validate token response

- add: session_id to the jwt generated token
This commit is contained in:
2024-12-20 17:46:04 -05:00
parent e0114fd832
commit 9d9e2bef05
4 changed files with 19 additions and 12 deletions

View File

@@ -1,4 +1,5 @@
use crate::database_client::DatabaseClientTrait;
use crate::database::GetUserResponse;
use argon2::{
password_hash::{
@@ -20,11 +21,11 @@ pub fn verify_password(password: &str, hash: &str) -> bool {
}
pub async fn verify_user<T: DatabaseClientTrait>(mut db_client: T,
username: &str, password: &str) -> Option<String> {
username: &str, password: &str) -> Option<GetUserResponse> {
let user = db_client.get_user_by_username(username).await.ok()?;
if verify_password(password, &user.hashed_password) {
Some(user.user_id.to_string())
Some(user)
} else {
None
}