mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-20 00:25:17 +00:00
Can create a new account
This commit is contained in:
@ -3,7 +3,8 @@ import { APIClient } from "../entities/APIClient";
|
||||
import { UserLoginTokens } from "../entities/UserLoginTokens";
|
||||
import { DatabaseHelper } from "./DatabaseHelper";
|
||||
import { UserHelper } from "./UserHelper";
|
||||
import { time } from "../utils/DateUtils";
|
||||
import { time, mysql_date } from "../utils/DateUtils";
|
||||
import { NewAccount } from "../entities/NewAccount";
|
||||
|
||||
/**
|
||||
* Account helper
|
||||
@ -16,6 +17,23 @@ const USERS_TOKENS_TABLE = "comunic_api_users_tokens";
|
||||
|
||||
export class AccountHelper {
|
||||
|
||||
/**
|
||||
* Create a new account
|
||||
*
|
||||
* @param info Information about the new account
|
||||
*/
|
||||
public static async Create(info: NewAccount) {
|
||||
const data = {
|
||||
nom: info.lastName,
|
||||
prenom: info.firstName,
|
||||
date_creation: mysql_date(),
|
||||
mail: info.email,
|
||||
password: this.CryptPassword(info.password)
|
||||
};
|
||||
|
||||
await DatabaseHelper.InsertRow(USER_TABLE, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given email address and password, try to sign in user
|
||||
*
|
||||
|
Reference in New Issue
Block a user