Fix few bad var

This commit is contained in:
osaajani 2020-04-02 19:10:54 +02:00
parent 73b82296a7
commit 89cb3db678
7 changed files with 25 additions and 21 deletions

View File

@ -75,7 +75,7 @@ namespace adapters;
/**
* Does the implemented service support reception callback.
*/
public static function meta_support_reception(): bool;
//public static function meta_support_reception(): bool;
/**
* Method called to send a SMS to a number.

View File

@ -262,7 +262,7 @@ namespace controllers\internals;
];
$internal_webhook = new Webhook($this->bdd);
$internal_webhook->trigger($id_user, \models\Webhook::TYPE_RECEIVE, $sended);
$internal_webhook->trigger($id_user, \models\Webhook::TYPE_RECEIVE, $received);
$internal_user = new User($this->bdd);
$internal_user->transfer_received($id_user, $received);

View File

@ -15,8 +15,12 @@ namespace controllers\internals;
{
protected $bdd;
public function __construct(\PDO $bdd)
public function __construct(?\PDO $bdd = null)
{
if ($bdd === null)
{
$bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD);
}
$this->bdd = $bdd;
}

View File

@ -222,23 +222,23 @@ namespace controllers\internals;
'status' => $status,
];
$new_user_id = $this->model_user->insert($user);
$new_id_user = $this->model_user->insert($user);
if (!$new_user_id)
if (!$new_id_user)
{
return false;
}
$success = $this->internal_setting->create_defaults_for_user($new_user_id);
$success = $this->internal_setting->create_defaults_for_user($new_id_user);
if (!$success)
{
$this->delete($new_user_id);
$this->delete($new_id_user);
return false;
}
return $new_user_id;
return $new_id_user;
}
/**
@ -265,10 +265,10 @@ namespace controllers\internals;
*
* @return bool : False if no transfer, true else
*/
public function transfer_received (int $id_user, array $received) :
public function transfer_received (int $id_user, array $received) : bool
{
$internal_setting = new Setting($this->bdd);
$settings = $internal_setting->gets_for_user($user_id);
$settings = $internal_setting->gets_for_user($id_user);
if (!$settings['transfer'] ?? false)
{

View File

@ -90,7 +90,7 @@ class Webhook extends StandardController
/**
* Trigger a webhook and transmit the signal to webhook daemon if needed.
* @param int $user_id : User to trigger the webhook for
* @param int $id_user : User to trigger the webhook for
* @param string $type : Type of webhook to trigger
* @param array $sms : The sms [
* int 'id' => SMS id,
@ -101,10 +101,10 @@ class Webhook extends StandardController
* ]
* @return bool : False if no trigger, true else
*/
private function trigger (int $user_id, string $type, array $sms)
public function trigger (int $id_user, string $type, array $sms)
{
$internal_setting = new Setting($this->bdd);
$settings = $internal_setting->gets_for_user($user_id);
$settings = $internal_setting->gets_for_user($id_user);
if (!$settings['webhook'] ?? false)
{

View File

@ -116,9 +116,9 @@ namespace controllers\publics;
}
$Tokenista = new \Ingenerator\Tokenista(APP_SECRET);
$token = $Tokenista->generate(3600, ['user_id' => $user['id']]);
$token = $Tokenista->generate(3600, ['id_user' => $user['id']]);
$reset_link = \descartes\Router::url('Connect', 'reset_password', ['user_id' => $user['id'], 'token' => $token]);
$reset_link = \descartes\Router::url('Connect', 'reset_password', ['id_user' => $user['id'], 'token' => $token]);
\controllers\internals\Tool::send_email($email, EMAIL_RESET_PASSWORD, ['reset_link' => $reset_link]);
@ -128,17 +128,17 @@ namespace controllers\publics;
/**
* Cette fonction permet à un utilisateur de re-définir son mot de passe.
*
* @param int $user_id : L'id du user dont on veut modifier le password
* @param int $id_user : L'id du user dont on veut modifier le password
* @param string $token : Le token permetttant de vérifier que l'opération est légitime
* @param optionnal $_POST['password'] : Le nouveau password à utiliser
*/
public function reset_password($user_id, $token)
public function reset_password($id_user, $token)
{
$password = $_POST['password'] ?? false;
$Tokenista = new \Ingenerator\Tokenista(APP_SECRET);
if (!$Tokenista->isValid($token, ['user_id' => $user_id]))
if (!$Tokenista->isValid($token, ['id_user' => $id_user]))
{
return $this->render('connect/reset-password-invalid');
}
@ -148,7 +148,7 @@ namespace controllers\publics;
return $this->render('connect/reset-password');
}
$this->internal_user->update_password($user_id, $password);
$this->internal_user->update_password($id_user, $password);
return $this->render('connect/reset-password-done');
}

View File

@ -166,8 +166,8 @@ class User extends \descartes\Controller
return $this->redirect(\descartes\Router::url('User', 'add'));
}
$user_id = $this->internal_user->create($email, $password, $admin, $status);
if (!$user_id)
$id_user = $this->internal_user->create($email, $password, $admin, $status);
if (!$id_user)
{
\FlashMessage\FlashMessage::push('danger', 'Impossible de créer ce user.');