Completed
Push — master ( 54c8bf...8a900a )
by Patrick
05:46 queued 04:07
created

oauth/index.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
require_once('vendor/autoload.php');
3
require_once('../Autoload.php');
4
5
if($_SERVER['REQUEST_URI'][0] == '/' && $_SERVER['REQUEST_URI'][1] == '/')
6
{
7
    $_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'], 1);
8
}
9
10
$app = new \Slim\App();
11
$app->get('/callbacks/{host}', 'oauthCallback');
12
13
function oauthCallback($request, $response, $args)
14
{
15
    $host = $args['host'];
16
    $auth = \Flipside\AuthProvider::getInstance();
17
    $provider = $auth->getSuplementalProviderByHost($host);
18
    if($provider === false)
19
    {
20
        return $response->withStatus(404);
21
    }
22
    $res = $provider->authenticate($request->getQueryParams(), $currentUser);
0 ignored issues
show
The variable $currentUser does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
23
    switch($res)
24
    {
25
        case \Flipside\Auth\Authenticator::SUCCESS:
26
            $response = $response->withHeader('Location', '/');
27
            break;
28
        default:
29
        case \Flipside\Auth\Authenticator::LOGIN_FAILED:
0 ignored issues
show
case \Flipside\Auth\Auth...?failed=1'); break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
30
            $response = $response->withHeader('Location', '/login.php?failed=1');
31
            break;
32
        case \Flipside\Auth\Authenticator::ALREADY_PRESENT:
33
            $response = $response->withHeader('Location', '/user_exists.php?src='.$host.'&uid='.$currentUser->getUID());
34
            break;
35
    }
36
    return $response->withStatus(302);
37
}
38
39
$app->run();
40
?>
41