This commit is contained in:
2022-10-02 20:51:06 +02:00
parent 71bdea4001
commit b20d3c418c
13 changed files with 821 additions and 61 deletions

View File

@@ -1 +0,0 @@
pub struct CookieService {}

View File

@@ -1,2 +1 @@
pub mod cookie_service;
pub mod users_service;

View File

@@ -1,5 +1,3 @@
use anyhow::anyhow;
use argon2::{password_hash::SaltString, Argon2, PasswordHash, PasswordHasher, PasswordVerifier};
use rand_core::OsRng;
@@ -36,7 +34,7 @@ impl UserService {
&self,
username: String,
password: String,
) -> anyhow::Result<Option<()>> {
) -> anyhow::Result<Option<String>> {
let rec = sqlx::query!(
r#"
SELECT * from users
@@ -49,7 +47,7 @@ impl UserService {
match rec {
Some(user) => match self.validate_password(password, user.password_hash)? {
true => Ok(Some(())),
true => Ok(Some(user.id.to_string())),
false => Ok(None),
},
None => Ok(None),