1
0
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:
2019-12-30 13:44:54 +01:00
parent 48cb254b9b
commit 994d1540dc
5 changed files with 76 additions and 1 deletions

View File

@ -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
*