MCPcopy Create free account
hub / github.com/actix/examples / query

Function query

auth/simple-auth-server/src/auth_handler.rs:65–82  ·  view source on GitHub ↗

Diesel query

(auth_data: AuthData, pool: web::Data<Pool>)

Source from the content-addressed store, hash-verified

63/// Diesel query
64fn query(auth_data: AuthData, pool: web::Data<Pool>) -> Result<SlimUser, ServiceError> {
65 use crate::schema::users::dsl::{email, users};
66
67 let mut conn = pool.get().unwrap();
68
69 let mut items = users
70 .filter(email.eq(&auth_data.email))
71 .load::<User>(&mut conn)?;
72
73 if let Some(user) = items.pop()
74 && let Ok(matching) = verify(&user.hash, &auth_data.password)
75 && matching
76 {
77 return Ok(user.into());
78 }
79 Err(ServiceError::Unauthorized)
80}

Callers 2

loginFunction · 0.70
query_charactersFunction · 0.50

Calls 2

verifyFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected