aboutsummaryrefslogtreecommitdiff
path: root/app/class/Controlleruser.php
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2020-04-27 13:35:29 +0200
committervincent-peugnet <v.peugnet@free.fr>2020-04-28 20:21:34 +0200
commitcba95c5eb19a33654a6f0995c6f9e0885b7afc20 (patch)
treea334a0fa3c074f44fe41a4114ea1853ac7f6c0e3 /app/class/Controlleruser.php
parentc832f91ca41490f69f478045c86038f9ef4a5cb5 (diff)
downloadwcms-cba95c5eb19a33654a6f0995c6f9e0885b7afc20.tar.gz
wcms-cba95c5eb19a33654a6f0995c6f9e0885b7afc20.zip
fix password max size
add error in hydrate
Diffstat (limited to 'app/class/Controlleruser.php')
-rw-r--r--app/class/Controlleruser.php35
1 files changed, 17 insertions, 18 deletions
diff --git a/app/class/Controlleruser.php b/app/class/Controlleruser.php
index 7f12e77..755b491 100644
--- a/app/class/Controlleruser.php
+++ b/app/class/Controlleruser.php
@@ -2,6 +2,9 @@
namespace Wcms;
+use Exception;
+use Throwable;
+
class Controlleruser extends Controller
{
@@ -33,10 +36,10 @@ class Controlleruser extends Controller
{
if ($this->user->iseditor()) {
$user = $this->usermanager->get($this->user);
- if ($user->hydrate($_POST)) {
- Model::sendflashmessage('User preferences have been successfully updated', 'success');
- } else {
- Model::sendflashmessage('There was a problem when updating preferences', 'warning');
+ try {
+ $user->hydrate($_POST, true);
+ } catch (\Throwable $th) {
+ Model::sendflashmessage('There was a problem when updating preferences : ' . $th->getMessage(), 'error');
}
if ($_POST['passwordhash']) {
$user->hashpassword();
@@ -54,15 +57,16 @@ class Controlleruser extends Controller
if ($this->user->iseditor() && isset($_POST['action']) && isset($_POST['id']) && !empty($_POST['id'])) {
if ($_POST['action'] == 'add' && isset($_POST['query'])) {
if (isset($_POST['user']) && $_POST['user'] == $this->user->id()) {
- $bookmark = new Bookmark();
- $bookmark->init($_POST['id'], $_POST['route'], $_POST['query'], [], $_POST['icon']);
- $usermanager = new Modeluser();
- $user = $usermanager->get($_POST['user']);
- $user->addbookmark($bookmark);
- $usermanager->add($user);
- } else {
- Config::addbookmark($_POST['id'], $_POST['query']);
- Config::savejson();
+ try {
+ $bookmark = new Bookmark($_POST);
+ $usermanager = new Modeluser();
+ $user = $usermanager->get($_POST['user']);
+ $user->addbookmark($bookmark);
+ $usermanager->add($user);
+ } catch (Throwable $th) {
+ Logger::errorex($th, true);
+ Model::sendflashmessage('Error while creating bookmark : ' . $th->getMessage(), 'error');
+ }
}
} elseif ($_POST['action'] == 'del') {
if (isset($_POST['user']) && $_POST['user'] == $this->user->id()) {
@@ -72,11 +76,6 @@ class Controlleruser extends Controller
$user->deletebookmark($id);
}
$usermanager->add($user);
- } else {
- foreach ($_POST['id'] as $id) {
- Config::deletebookmark($id);
- }
- Config::savejson();
}
}
}