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

User::actionLogout()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 12
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Apps\Controller\Front;
4
5
use Extend\Core\Arch\FrontAppController;
6
use Ffcms\Core\App;
7
use Ffcms\Core\Exception\ForbiddenException;
8
9
/**
10
 * Class User - standard user controller: login/signup/logout/etc
11
 * @package Apps\Controller\Front
12
 */
13
class User extends FrontAppController
14
{
15
    const EVENT_USER_LOGIN_SUCCESS = 'user.login.success';
16
    const EVENT_USER_LOGIN_FAIL = 'user.login.fail';
17
    const EVENT_USER_REGISTER_SUCCESS = 'user.signup.success';
18
    const EVENT_USER_REGISTER_FAIL = 'user.signup.fail';
19
    const EVENT_USER_RECOVERY_SUCCESS = 'user.recovery.success';
20
21
    use User\ActionLogin {
0 ignored issues
show
Bug introduced by
The trait Apps\Controller\Front\User\ActionLogin requires the property $query which is not provided by Apps\Controller\Front\User.
Loading history...
22
        login as actionLogin;
23
    }
24
25
    use User\ActionSignup {
0 ignored issues
show
introduced by
The trait Apps\Controller\Front\User\ActionSignup requires some properties which are not provided by Apps\Controller\Front\User: $query, $_userObject
Loading history...
26
        signup as actionSignup;
27
    }
28
29
    use User\ActionSocialAuth {
0 ignored issues
show
introduced by
The trait Apps\Controller\Front\User\ActionSocialAuth requires some properties which are not provided by Apps\Controller\Front\User: $identifier, $_userObject
Loading history...
30
        socialauth as actionSocialauth;
31
    }
32
33
    use User\ActionRecovery {
0 ignored issues
show
Bug introduced by
The trait Apps\Controller\Front\User\ActionRecovery requires the property $user_id which is not provided by Apps\Controller\Front\User.
Loading history...
34
        recovery as actionRecovery;
35
    }
36
37
    use User\ActionApprove {
38
        approve as actionApprove;
39
    }
40
41
    /**
42
     * Make logout if user is signIn
43
     * @throws ForbiddenException
44
     */
45
    public function actionLogout()
46
    {
47
        // check if user authorized
48
        if (!App::$User->isAuth()) {
49
            throw new ForbiddenException(__('You are not authorized user'));
50
        }
51
52
        // unset session data
53
        App::$Session->invalidate();
54
55
        // redirect to main
56
        $this->response->redirect('/');
57
    }
58
}
59