formatting changes

This commit is contained in:
Reid 2023-09-03 16:21:24 -07:00
parent e237cd9b8d
commit 542d23d7c7
Signed by: reidlab
GPG key ID: 6C9EAA3364F962C8
3 changed files with 12 additions and 6 deletions

View file

@ -34,6 +34,7 @@ _these features are implemented_
## todo ## todo
- when gjp2 is finally dropped we should 100% swap so it works in two point two
- green name users (fuck green names!!) - green name users (fuck green names!!)
- move authorization logic to (./src/helpers/accounts.rs)[./src/helpers/accounts.rs] - move authorization logic to (./src/helpers/accounts.rs)[./src/helpers/accounts.rs]
- maybe swap to timestamp type instead of `(TO_CHAR(CURRENT_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS.MS'))` (thats REALLY ugly!!) - maybe swap to timestamp type instead of `(TO_CHAR(CURRENT_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS.MS'))` (thats REALLY ugly!!)

View file

@ -34,18 +34,21 @@ pub fn login_account(input: Form<FromLoginAccount>) -> status::Custom<&'static s
{ {
use crate::schema::accounts::dsl::*; use crate::schema::accounts::dsl::*;
let account_id_password_result = accounts let query_result = accounts
.select((id, password)) .select((id, password))
.filter(username.eq(input.userName.clone())) .filter(username.eq(input.userName.clone()))
.get_result::<(i32, String)>(connection); .get_result::<(i32, String)>(connection);
match account_id_password_result { match query_result {
Ok(account_id_password) => { Ok((
let user_id = helpers::accounts::get_user_id_from_account_id(account_id_password.0); account_id_val,
password_val
)) => {
let user_id = helpers::accounts::get_user_id_from_account_id(account_id_val);
match verify_password(input.password.clone().as_bytes(), account_id_password.1.as_str()) { match verify_password(input.password.clone().as_bytes(), password_val.as_str()) {
Ok(_) => return status::Custom(Status::Ok, Ok(_) => return status::Custom(Status::Ok,
Box::leak(format!("{},{}", account_id_password.0, user_id).into_boxed_str()) Box::leak(format!("{},{}", account_id_val, user_id).into_boxed_str())
), ),
Err(_) => return status::Custom(Status::Ok, "-11") Err(_) => return status::Custom(Status::Ok, "-11")
}; };

View file

@ -66,6 +66,7 @@ pub fn register_account(input: Form<FormRegisterAccount>) -> status::Custom<&'st
gjp2: generate_hash(helpers::encryption::get_gjp2(input.password.clone())), gjp2: generate_hash(helpers::encryption::get_gjp2(input.password.clone())),
email: input.email.clone() email: input.email.clone()
}; };
inserted_account = diesel::insert_into(accounts) inserted_account = diesel::insert_into(accounts)
.values(&new_account) .values(&new_account)
.get_result::<Account, >(connection) .get_result::<Account, >(connection)
@ -83,6 +84,7 @@ pub fn register_account(input: Form<FormRegisterAccount>) -> status::Custom<&'st
username: input.userName.clone(), username: input.userName.clone(),
registered: 1 registered: 1
}; };
diesel::insert_into(users) diesel::insert_into(users)
.values(&new_user) .values(&new_user)
.get_result::<User, >(connection) .get_result::<User, >(connection)