more level boilerplate
This commit is contained in:
parent
9ecb8b4ae8
commit
66489506ac
3 changed files with 34 additions and 47 deletions
|
@ -34,7 +34,7 @@ _these features are implemented_
|
|||
|
||||
## todo
|
||||
|
||||
- clean auth function (wtf is that!)
|
||||
- add udid auth to auth function
|
||||
- probably work on the code warnings we get hehe
|
||||
- <small>green name users...</small> (add udid auth to auth function, use userName instead of accountID in uploading levels, and it goes on and on and on <small>and on...</small>)
|
||||
- add level parsing
|
||||
- maybe swap to timestamp type instead of `(TO_CHAR(CURRENT_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS.MS'))` (thats REALLY ugly!!)
|
|
@ -1,51 +1,36 @@
|
|||
// use password_auth::verify_password;
|
||||
// use rocket::form::Form;
|
||||
// use rocket::http::Status;
|
||||
// use rocket::response::status;
|
||||
use password_auth::verify_password;
|
||||
use rocket::form::Form;
|
||||
use rocket::http::Status;
|
||||
use rocket::response::status;
|
||||
|
||||
// use diesel::prelude::*;
|
||||
use diesel::prelude::*;
|
||||
|
||||
// use crate::helpers;
|
||||
// use crate::db;
|
||||
use crate::helpers;
|
||||
use crate::db;
|
||||
|
||||
// #[derive(FromForm)]
|
||||
// pub struct FromLoginAccount {
|
||||
// accountID: i32,
|
||||
// gjp: String
|
||||
// }
|
||||
|
||||
// #[post("/accounts/loginGJAccount.php", data = "<input>")]
|
||||
// pub fn login_account(input: Form<FromLoginAccount>) -> status::Custom<&'static str> {
|
||||
// let connection = &mut db::establish_connection_pg();
|
||||
#[derive(FromForm)]
|
||||
pub struct FormUploadLevel {
|
||||
accountID: i32,
|
||||
|
||||
// // account verification
|
||||
// let (user_id, account_id): (i32, i32);
|
||||
password: Option<String>,
|
||||
gjp: Option<String>,
|
||||
gjp2: Option<String>,
|
||||
}
|
||||
|
||||
// {
|
||||
// use crate::schema::accounts::dsl::*;
|
||||
#[post("/uploadGJLevel21.php", data = "<input>")]
|
||||
pub fn upload_level(input: Form<FormUploadLevel>) -> status::Custom<&'static str> {
|
||||
let connection = &mut db::establish_connection_pg();
|
||||
|
||||
// let query_result = accounts
|
||||
// .select((id, password))
|
||||
// .filter(username.eq(input.userName.clone()))
|
||||
// .get_result::<(i32, String)>(connection);
|
||||
|
||||
// match query_result {
|
||||
// Ok((
|
||||
// account_id_val,
|
||||
// password_val
|
||||
// )) => {
|
||||
// user_id = helpers::accounts::get_user_id_from_account_id(account_id_val);
|
||||
|
||||
// match verify_password(input.password.clone().as_bytes(), password_val.as_str()) {
|
||||
// Ok(_) => return status::Custom(Status::Ok,
|
||||
// Box::leak(format!("{},{}", account_id_val, user_id).into_boxed_str())
|
||||
// ),
|
||||
// Err(_) => return status::Custom(Status::Ok, "-11")
|
||||
// };
|
||||
// },
|
||||
// Err(_) => return status::Custom(Status::Ok, "-1")
|
||||
// }
|
||||
// }
|
||||
// account verification
|
||||
let (user_id_val, account_id_val): (i32, i32);
|
||||
|
||||
// return status::Custom(Status::Ok, "1")
|
||||
// }
|
||||
match helpers::accounts::auth(input.accountID.clone(), input.password.clone(), input.gjp.clone(), input.gjp2.clone()) {
|
||||
Ok((user_id, account_id)) => {
|
||||
user_id_val = user_id;
|
||||
account_id_val = account_id;
|
||||
},
|
||||
Err(_) => return status::Custom(Status::Ok, "-1")
|
||||
};
|
||||
|
||||
return status::Custom(Status::Ok, "1")
|
||||
}
|
|
@ -32,6 +32,8 @@ fn rocket() -> _ {
|
|||
endpoints::accounts::login_account::login_account,
|
||||
endpoints::accounts::register_account::register_account,
|
||||
|
||||
endpoints::users::get_users::get_users
|
||||
endpoints::users::get_users::get_users,
|
||||
|
||||
endpoints::levels::upload_level::upload_level
|
||||
])
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue