Conditions | 4 |
Paths | 3 |
Total Lines | 24 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
30 | public function password(): ?string |
||
31 | { |
||
32 | // check if user is authed |
||
33 | if (!App::$User->isAuth()) { |
||
34 | throw new ForbiddenException(); |
||
35 | } |
||
36 | |||
37 | // get user object and create model with user object |
||
38 | $user = App::$User->identity(); |
||
39 | $model = new FormPasswordChange($user); |
||
|
|||
40 | |||
41 | // check if form is submited and validation is passed |
||
42 | if ($model->send() && $model->validate()) { |
||
43 | $model->make(); |
||
44 | App::$Event->run(static::EVENT_CHANGE_PASSWORD, [ |
||
45 | 'model' => $model |
||
46 | ]); |
||
47 | |||
48 | App::$Session->getFlashBag()->add('success', __('Password is successful changed')); |
||
49 | } |
||
50 | |||
51 | // set response output |
||
52 | return $this->view->render('profile/password', [ |
||
53 | 'model' => $model |
||
54 | ]); |
||
57 |