MCPcopy Create free account
hub / github.com/Rust-Web-Development/code / register

Function register

ch_11/src/routes/authentication.rs:16–29  ·  view source on GitHub ↗
(store: Store, account: Account)

Source from the content-addressed store, hash-verified

14use crate::types::account::{Account, AccountId, Session};
15
16pub 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
31pub async fn login(store: Store, login: Account) -> Result<impl warp::Reply, warp::Rejection> {
32 match store.get_account(login.email).await {

Callers

nothing calls this directly

Calls 2

hash_passwordFunction · 0.70
add_accountMethod · 0.45

Tested by

no test coverage detected