(store: Store, account: Account)
| 14 | use crate::types::account::{Account, AccountId, Session}; |
| 15 | |
| 16 | pub async fn register(store: Store, account: Account) -> Result<impl warp::Reply, warp::Rejection> { |
| 17 | let hashed_password = hash_password(account.password.as_bytes()); |
| 18 | |
| 19 | let account = Account { |
| 20 | id: account.id, |
| 21 | email: account.email, |
| 22 | password: hashed_password, |
| 23 | }; |
| 24 | |
| 25 | match store.add_account(account).await { |
| 26 | Ok(_) => Ok(warp::reply::json(&"Account added".to_string())), |
| 27 | Err(e) => Err(warp::reject::custom(e)), |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | pub async fn login(store: Store, login: Account) -> Result<impl warp::Reply, warp::Rejection> { |
| 32 | match store.get_account(login.email).await { |
nothing calls this directly
no test coverage detected