Completed
Push — master ( c0ef62...66e43c )
by Andrii
11:39
created

AuthAction   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 12 4
1
<?php
2
3
/*
4
 * OAuth2 client for yii2 to login with HIAM server
5
 *
6
 * @link      https://github.com/hiqdev/yii2-hiam-authclient
7
 * @package   yii2-hiam-authclient
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hiam\authclient;
13
14
use Yii;
15
16
class AuthAction extends \yii\authclient\AuthAction
17
{
18
    public function run()
19
    {
20
        /// Fixed problem with repeated return from HIAM
21
        try {
22
            return parent::run();
23
        } catch (\Exception $e) {
24
            $isLoggedIn = !empty(Yii::$app->user->id);
25
            if ($e->getMessage() === 'Invalid auth state parameter.' && $isLoggedIn) {
26
                return $this->redirectSuccess();
27
            }
28
        }
29
    }
30
}
31