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

AuthAction::run()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 4
nc 3
nop 0
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