checking for open routes which require no aut in wall_entry

This commit is contained in:
shockrah 2020-06-02 01:29:05 -07:00
parent d02f2d9eb7
commit 68aeb50175

View File

@ -1,10 +1,12 @@
use mysql_async::Conn;
use mysql_async::prelude::{params, Queryable};
use hyper::{Response, Body};
use std::collections::HashMap;
use crate::routes;
pub enum AuthReason {
Good,
Good, //passed regular check
OpenAuth, // route does not require auth
LimitPassed,
NoKey,
InternalFailure,
@ -24,8 +26,17 @@ fn check_key_row(row: Option<(String, i32, i32)>) -> AuthReason {
None => NoKey
}
}
pub async fn wall_entry(conn: Conn, params: &HashMap<&str, &str>) -> AuthReason {
fn open_route(path: &str) -> bool {
return path == routes::INVITE_JOIN
}
pub async fn wall_entry(path: &str, conn: Conn, params: &HashMap<&str, &str>) -> AuthReason {
// Start by Checking if the api key is in our keystore
if open_route(path) {
AuthReason::OpenAuth
}
else {
if let Some(key) = params.get("key") {
// (id, limit, current counter)
let db_request: Result<(Conn, Option<(String, i32, i32)>), mysql_async::error::Error> = conn
@ -41,8 +52,5 @@ pub async fn wall_entry(conn: Conn, params: &HashMap<&str, &str>) -> AuthReason
else {
AuthReason::NoKey
}
}
pub fn wall_failure(resp: &Response<Body>) {
unimplemented!()
}
}