/**
* Create a user upon call from frontend
* This API method will be called from Controller of this module
*
* @param String $userLogin
* @param String $userPassword
* @param String $userEmail
* @return Boolean
*/
public function createUser($userLogin, $userPassword, $userEmail)
{
if ($userLogin and $userPassword) {
$userManager = UserManagerAPI::getInstance();
if (!$this->userManagerModel->userEmailExists($userEmail) and !$this->userManagerModel->userExists($userLogin)) {
$password = Common::unsanitizeInputValue($userPassword);
UserManager::checkPassword($password);
$passwordTransformed = UserManager::getPasswordHash($password);
$token_auth = $userManager->getTokenAuth($userEmail, $passwordTransformed);
try {
$this->userManagerModel->addUser($userEmail, $passwordTransformed, $userEmail, $userLogin, $token_auth, Date::now()->getDatetime());
return true;
} catch (Exception $e) {
//throw new Exception($e->getMessage());
$this->__errors[] = 'Error in creating the user in database.';
}
} else {
$this->__errors[] = 'User email already exists or the login name already exists';
}
}
return false;
}