| @@ 334-355 (lines=22) @@ | ||
| 331 | * @throws \Ffcms\Core\Exception\NativeException |
|
| 332 | * @throws ForbiddenException |
|
| 333 | */ |
|
| 334 | public function actionSettings() |
|
| 335 | { |
|
| 336 | // check if auth |
|
| 337 | if (!App::$User->isAuth()) { |
|
| 338 | throw new ForbiddenException(); |
|
| 339 | } |
|
| 340 | // get user object |
|
| 341 | $user = App::$User->identity(); |
|
| 342 | // create model and pass user object |
|
| 343 | $model = new FormSettings($user); |
|
| 344 | ||
| 345 | // check if form is submited |
|
| 346 | if ($model->send() && $model->validate()) { |
|
| 347 | $model->save(); |
|
| 348 | App::$Session->getFlashBag()->add('success', __('Profile data are successful updated')); |
|
| 349 | } |
|
| 350 | ||
| 351 | // render view |
|
| 352 | return App::$View->render('settings', [ |
|
| 353 | 'model' => $model->filter() |
|
| 354 | ]); |
|
| 355 | } |
|
| 356 | ||
| 357 | /** |
|
| 358 | * Action change user password |
|
| @@ 364-385 (lines=22) @@ | ||
| 361 | * @throws \Ffcms\Core\Exception\NativeException |
|
| 362 | * @throws ForbiddenException |
|
| 363 | */ |
|
| 364 | public function actionPassword() |
|
| 365 | { |
|
| 366 | // check if user is authed |
|
| 367 | if (!App::$User->isAuth()) { |
|
| 368 | throw new ForbiddenException(); |
|
| 369 | } |
|
| 370 | ||
| 371 | // get user object and create model with user object |
|
| 372 | $user = App::$User->identity(); |
|
| 373 | $model = new FormPasswordChange($user); |
|
| 374 | ||
| 375 | // check if form is submited and validation is passed |
|
| 376 | if ($model->send() && $model->validate()) { |
|
| 377 | $model->make(); |
|
| 378 | App::$Session->getFlashBag()->add('success', __('Password is successful changed')); |
|
| 379 | } |
|
| 380 | ||
| 381 | // set response output |
|
| 382 | return App::$View->render('password', [ |
|
| 383 | 'model' => $model->filter() |
|
| 384 | ]); |
|
| 385 | } |
|
| 386 | ||
| 387 | /** |
|
| 388 | * Show users in blacklist and allow add new users |
|