Skip to content

Commit

Permalink
Verifica conexão ao banco dados na rota de recuperação de senha
Browse files Browse the repository at this point in the history
/admin/forgot_password

- Tratamento de erro em MyModel->fetch ()
  • Loading branch information
jairpro committed Sep 19, 2020
1 parent 1a1bfb4 commit b099feb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions modules/my-model/MyModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ function fetchAll($params=null, $sql=null) {

function fetch($params=null, $sql=null) {
$this->setup($params, $sql);
if (!$this->sth) {
return false;
}
$value = $this->sth->fetch();
return $value;
}
Expand Down
4 changes: 3 additions & 1 deletion src/controllers/ForgotPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ function store($req, $res) {
if (!isset($data['user'])) {
$res->status(400)->send(['error' => "Missing the user field."]);
}

$user = $data['user'];

$model = new $this->modelClass();
if (!$model->setup()) {
$res->status(500)->send(['error'=>'Database connection failure.']);
}

$found = $model->findOne([
'or'=>[
Expand Down

0 comments on commit b099feb

Please sign in to comment.