Completed
Push — master ( 5b1359...f1abe4 )
by Clinton
03:50
created

callback::doGet()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 28
rs 8.8571
cc 1
eloc 21
nc 1
nop 2
1
<?php
2
3
namespace cvweiss\projectbase\Controller\auth\eve;
4
5
use zkillboard\crestsso\CrestSSO;
6
use cvweiss\projectbase\Config;
7
use cvweiss\projectbase\Mongo;
8
use cvweiss\projectbase\Session;
9
10
class callback
11
{
12
    public function doGet($view, $params)
13
    { 
14
        unset($params);
15
        $auth = Config::getInstance()->get("oauth2");
16
        $eve = $auth['eve'];
17
18
        $sso = new CrestSSO($eve['client_id'], $eve['client_secret'], $eve['redirect_uris'][0], $eve['scopes'], '/');
19
        $code = filter_input(INPUT_GET, 'code');
20
        $state = filter_input(INPUT_GET, 'state');
21
        $userInfo = $sso->handleCallback($code, $state, Session::getSession());
0 ignored issues
show
Unused Code introduced by
The call to CrestSSO::handleCallback() has too many arguments starting with $state.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
22
23
        $charID = $userInfo['characterID'];
24
        $id = "auth:eve:" . $charID;
25
        $user = Mongo::get()->findDoc("users", ['id' => $id], null, true);
26
27
        $user->setAll([
28
                "id" => $id,
29
                "name" => $userInfo['characterName'],
30
                "email" => null,
31
                "image" => "https://imageserver.eveonline.com/Character/${charID}_256.jpg",
32
                "oauth2" => "eve",
33
                "refresh_token" => $userInfo['refreshToken']
34
        ]);
35
        $user->save();
36
37
        Session::getSession()->set("userID", $id);
38
        $view->redirect('/', 302);
39
    }
40
}
41