Code Duplication    Length = 24-25 lines in 2 locations

oauth2callback.php 2 locations

@@ 27-51 (lines=25) @@
24
25
switch($src)
26
{
27
    case 'google':
28
        $google = $auth->getMethodByName('Auth\GoogleAuthenticator');
29
        if(!isset($_GET['code']))
30
        {
31
            $google->redirect();
32
            die();
33
        }
34
        else
35
        {
36
            $res = $google->authenticate($_GET['code'], $current_user);
37
            switch($res)
38
            {
39
                case \Auth\Authenticator::SUCCESS:
40
                    header('Location: '.$ref);
41
                    die();
42
                default:
43
                case \Auth\Authenticator::LOGIN_FAILED:
44
                    header('Location: login.php');
45
                    die();
46
                case \Auth\Authenticator::ALREADY_PRESENT:
47
                    header('Location: user_exists.php?src=google&uid='.$current_user->uid);
48
                    die();
49
            }
50
        }
51
        break;
52
    case 'twitter':
53
        $twitter = $auth->getMethodByName('Auth\TwitterAuthenticator');
54
        if(!isset($_GET['oauth_token']) || !isset($_GET['oauth_verifier']))
@@ 77-100 (lines=24) @@
74
            }
75
        }
76
        break;
77
    case 'gitlab':
78
        $gitlab = $auth->getMethodByName('Auth\OAuth2\GitLabAuthenticator');
79
        if(!isset($_GET['code']))
80
        {
81
            $google->redirect();
82
            die();
83
        }
84
        else
85
        {
86
            $res = $gitlab->authenticate($_GET['code'], $current_user);
87
            switch($res)
88
            {
89
                case \Auth\Authenticator::SUCCESS:
90
                    header('Location: '.$ref);
91
                    die();
92
                default:
93
                case \Auth\Authenticator::LOGIN_FAILED:
94
                    header('Location: login.php');
95
                    die();
96
                case \Auth\Authenticator::ALREADY_PRESENT:
97
                    header('Location: user_exists.php?src=gitlab&uid='.$current_user->uid);
98
                    die();
99
            }
100
        }
101
        //Generic OAuth...
102
    default:
103
        print_r($_SERVER);