mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-07-15 19:58:05 +00:00
Can create new accounts
This commit is contained in:
src
@ -1,17 +1,29 @@
|
||||
use crate::constants::database_tables_names::{USER_ACCESS_TOKENS_TABLE, USERS_TABLE};
|
||||
use crate::data::api_client::APIClient;
|
||||
use crate::data::error::{ExecError, ResultBoxError};
|
||||
use crate::data::new_account::NewAccount;
|
||||
use crate::data::user::UserID;
|
||||
use crate::data::user_token::UserAccessToken;
|
||||
use crate::helpers::{database, user_helper};
|
||||
use crate::helpers::database::{DeleteQuery, InsertQuery, QueryInfo};
|
||||
use crate::utils::crypt_utils::{crypt_pass, rand_str};
|
||||
use crate::utils::date_utils::time;
|
||||
use crate::utils::date_utils::{mysql_date, time};
|
||||
|
||||
/// Account helper
|
||||
///
|
||||
/// @author Pierre Hubert
|
||||
|
||||
/// Create a new account
|
||||
pub fn create(new_account: &NewAccount) -> ResultBoxError {
|
||||
database::InsertQuery::new(USERS_TABLE)
|
||||
.add_str("nom", &new_account.first_name)
|
||||
.add_str("prenom", &new_account.last_name)
|
||||
.add_str("date_creation", &mysql_date())
|
||||
.add_str("mail", &new_account.email)
|
||||
.add_str("password", &crypt_pass(&new_account.password)?)
|
||||
.insert_drop_result()
|
||||
}
|
||||
|
||||
/// Attempt to sign-in user
|
||||
///
|
||||
/// In this version of the api, we consider that there is only one login token required
|
||||
|
Reference in New Issue
Block a user