Test Failed
Push — master ( e3c39f...fe570d )
by Mihail
07:20
created

Apps/Controller/Front/Profile/ActionPassword.php (1 issue)

Checks if used container constants are declared or listed as dependencies.

Bug Major
1
<?php
2
3
4
namespace Apps\Controller\Front\Profile;
5
6
use Apps\Model\Front\Profile\FormPasswordChange;
7
use Ffcms\Core\App;
8
use Ffcms\Core\Arch\View;
9
use Ffcms\Core\Exception\ForbiddenException;
10
use Ffcms\Core\Network\Response;
11
use Symfony\Component\HttpFoundation\Request;
12
13
/**
14
 * Trait ActionPassword
15
 * @package Apps\Controller\Front\Profile
16
 * @property View $view
17
 * @property Request $request
18
 * @property Response $response
19
 * @method array getConfigs
20
 */
21
trait ActionPassword
22
{
23
24
    /**
25
     * Action change user password
26
     * @return string
27
     * @throws \Ffcms\Core\Exception\SyntaxException
28
     * @throws ForbiddenException
29
     */
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, [
0 ignored issues
show
The constant Apps\Controller\Front\Pr...::EVENT_CHANGE_PASSWORD was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
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
        ]);
55
    }
56
}
57