fixed auth module not using str version of the secret key

This commit is contained in:
shockrah 2020-07-13 20:31:14 -07:00
parent ed6c19314a
commit 0a0967d196

View File

@ -21,17 +21,30 @@ pub async fn wall_entry(path: &str, pool: &Pool, params: &serde_json::Value) ->
}
else {
if let Some(key) = params.get("secret") {
let key_str = key.as_str();
let conn = pool.get_conn().await?;
// (id, name, secret)
let (_con, row): (_, Option<(UBigInt, VarChar)>) = conn
.first_exec(r"SELECT userid, name FROM keys WHERE secret = :secret ", mysql_async::params!{ "secret" => key})
.await?;
// yeayea i no
match row {
Some(_) => Ok(AuthReason::Good),
None => Ok(AuthReason::NoKey)
type row_type = Option<(UBigInt, VarChar)>;
let db_result: Result<(_, row_type), mysql_async::error::Error> = conn
.first_exec(r"SELECT id, name FROM members WHERE secret = :secret ", mysql_async::params!{ "secret" => key_str})
.await;
match db_result {
Ok((_, row)) => {
match row{
Some(_) => Ok(AuthReason::Good),
None => Ok(AuthReason::NoKey)
}
}
Err(e) => {
println!("Issue fetching auth data {:?}", e);
Ok(AuthReason::NoKey)
}
}
//let (_con, row): (_, Option<(UBigInt, VarChar)>) = conn
// .first_exec(r"SELECT userid, name FROM keys WHERE secret = :secret ", mysql_async::params!{ "secret" => key})
// .await;
}
else {
Ok(AuthReason::NoKey)