Passed
Pull Request — master (#258)
by
unknown
03:54
created
app/Http/Controllers/OAuth/GithubController.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -13,18 +13,18 @@  discard block
 block discarded – undo
13 13
 {
14 14
     public function redirectTo()
15 15
     {
16
-        $accountModel = new AccountModel();
16
+        $accountModel=new AccountModel();
17 17
         $info=$accountModel->detail(Auth::user()->id);
18
-        if(Auth::check() && $info['contest_account']){
18
+        if (Auth::check() && $info['contest_account']) {
19 19
             return redirect('/account/settings');
20 20
         }
21
-        if(Auth::check() && $accountModel->getExtra(Auth::user()->id ,'github_id')){
22
-            return view('oauth.index',[
21
+        if (Auth::check() && $accountModel->getExtra(Auth::user()->id, 'github_id')) {
22
+            return view('oauth.index', [
23 23
                 'page_title'=>"OAuth",
24 24
                 'site_title'=>config("app.name"),
25 25
                 'navigation'=>"OAuth",
26 26
                 'platform' => 'Github',
27
-                'display_html' => 'You\'re already tied to the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br />
27
+                'display_html' => 'You\'re already tied to the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br />
28 28
                 You can choose to unbind or go back to the homepage',
29 29
                 'buttons' => [
30 30
                     [
@@ -44,19 +44,19 @@  discard block
 block discarded – undo
44 44
 
45 45
     public function handleCallback()
46 46
     {
47
-        try{
48
-            $github_user = Socialite::driver('github')->user();
49
-        }catch(\Laravel\Socialite\Two\InvalidStateException $e){
47
+        try {
48
+            $github_user=Socialite::driver('github')->user();
49
+        } catch (\Laravel\Socialite\Two\InvalidStateException $e) {
50 50
             return redirect('/');
51 51
         }
52 52
 
53
-        $accountModel = new AccountModel();
54
-        if(Auth::check()){
55
-            $user_id = Auth::user()->id;
56
-            $ret = $accountModel->findExtra('github_id',$github_user->id);
57
-            if(!empty($ret) && $ret['uid'] != $user_id){
58
-                $user = UserModel::find($ret['uid']);
59
-                return view('oauth.index',[
53
+        $accountModel=new AccountModel();
54
+        if (Auth::check()) {
55
+            $user_id=Auth::user()->id;
56
+            $ret=$accountModel->findExtra('github_id', $github_user->id);
57
+            if (!empty($ret) && $ret['uid']!=$user_id) {
58
+                $user=UserModel::find($ret['uid']);
59
+                return view('oauth.index', [
60 60
                     'page_title'=>"OAuth",
61 61
                     'site_title'=>config("app.name"),
62 62
                     'navigation'=>"OAuth",
@@ -71,17 +71,17 @@  discard block
 block discarded – undo
71 71
                     ]
72 72
                 ]);
73 73
             }
74
-            $accountModel->setExtra($user_id,'github_id',$github_user->id);
75
-            $accountModel->setExtra($user_id,'github_email',$github_user->email);
76
-            $accountModel->setExtra($user_id,'github_nickname',$github_user->nickname);
77
-            $accountModel->setExtra($user_id,'github_homepage',($github_user->user)['html_url']);
78
-            $accountModel->setExtra($user_id,'github_token',$github_user->token,101);
79
-            return view('oauth.index',[
74
+            $accountModel->setExtra($user_id, 'github_id', $github_user->id);
75
+            $accountModel->setExtra($user_id, 'github_email', $github_user->email);
76
+            $accountModel->setExtra($user_id, 'github_nickname', $github_user->nickname);
77
+            $accountModel->setExtra($user_id, 'github_homepage', ($github_user->user)['html_url']);
78
+            $accountModel->setExtra($user_id, 'github_token', $github_user->token, 101);
79
+            return view('oauth.index', [
80 80
                 'page_title'=>"OAuth",
81 81
                 'site_title'=>config("app.name"),
82 82
                 'navigation'=>"OAuth",
83 83
                 'platform' => 'Github',
84
-                'display_html' => 'You have successfully tied up the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br />
84
+                'display_html' => 'You have successfully tied up the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br />
85 85
                 You can log in to '.config("app.name").' later using this account',
86 86
                 'buttons' => [
87 87
                     [
@@ -90,18 +90,18 @@  discard block
 block discarded – undo
90 90
                     ],
91 91
                 ]
92 92
             ]);
93
-        }else{
94
-            $ret = $accountModel->findExtra('github_id',$github_user->id);
95
-            if(!empty($ret)){
93
+        } else {
94
+            $ret=$accountModel->findExtra('github_id', $github_user->id);
95
+            if (!empty($ret)) {
96 96
                 Auth::loginUsingId($ret['uid']);
97
-                $user_id = Auth::user()->id;
98
-                $accountModel->setExtra($user_id,'github_email',$github_user->email);
99
-                $accountModel->setExtra($user_id,'github_nickname',$github_user->nickname);
100
-                $accountModel->setExtra($user_id,'github_homepage',($github_user->user)['html_url']);
101
-                $accountModel->setExtra($user_id,'github_token',$github_user->token,101);
97
+                $user_id=Auth::user()->id;
98
+                $accountModel->setExtra($user_id, 'github_email', $github_user->email);
99
+                $accountModel->setExtra($user_id, 'github_nickname', $github_user->nickname);
100
+                $accountModel->setExtra($user_id, 'github_homepage', ($github_user->user)['html_url']);
101
+                $accountModel->setExtra($user_id, 'github_token', $github_user->token, 101);
102 102
                 return redirect('/');
103
-            }else{
104
-                return view('oauth.index',[
103
+            } else {
104
+                return view('oauth.index', [
105 105
                     'page_title'=>"OAuth",
106 106
                     'site_title'=>config("app.name"),
107 107
                     'navigation'=>"OAuth",
@@ -124,16 +124,16 @@  discard block
 block discarded – undo
124 124
 
125 125
     public function unbind()
126 126
     {
127
-        $accountModel = new AccountModel();
128
-        if($accountModel->getExtra(Auth::user()->id ,'github_id')){
129
-            return view('oauth.index',[
127
+        $accountModel=new AccountModel();
128
+        if ($accountModel->getExtra(Auth::user()->id, 'github_id')) {
129
+            return view('oauth.index', [
130 130
                 'page_title'=>"OAuth",
131 131
                 'site_title'=>config("app.name"),
132 132
                 'navigation'=>"OAuth",
133 133
                 'platform' => 'Github',
134 134
                 'display_html' => 'You are trying to unbind the following two : <br />
135 135
                 Your '.config("app.name").' account : <span class="text-info">'.Auth::user()->email.'</span><br />
136
-                This Github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br />
136
+                This Github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br />
137 137
                 Make your decision carefully, although you can later establish the binding again',
138 138
                 'buttons' => [
139 139
                     [
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
                     ],
148 148
                 ]
149 149
             ]);
150
-        }else{
151
-            return view('oauth.index',[
150
+        } else {
151
+            return view('oauth.index', [
152 152
                 'page_title'=>"OAuth",
153 153
                 'site_title'=>config("app.name"),
154 154
                 'navigation'=>"OAuth",
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
 
167 167
     public function confirmUnbind()
168 168
     {
169
-        $accountModel = new AccountModel();
170
-        $user_id = Auth::user()->id;
171
-        if($accountModel->getExtra($user_id ,'github_id')){
172
-            $accountModel->setExtra($user_id,'github_id',null);
173
-            $accountModel->setExtra($user_id,'github_email',null);
174
-            $accountModel->setExtra($user_id,'github_nickname',null);
175
-            $accountModel->setExtra($user_id,'github_homepage',null);
176
-            $accountModel->setExtra($user_id,'github_token',null);
177
-            return view('oauth.index',[
169
+        $accountModel=new AccountModel();
170
+        $user_id=Auth::user()->id;
171
+        if ($accountModel->getExtra($user_id, 'github_id')) {
172
+            $accountModel->setExtra($user_id, 'github_id', null);
173
+            $accountModel->setExtra($user_id, 'github_email', null);
174
+            $accountModel->setExtra($user_id, 'github_nickname', null);
175
+            $accountModel->setExtra($user_id, 'github_homepage', null);
176
+            $accountModel->setExtra($user_id, 'github_token', null);
177
+            return view('oauth.index', [
178 178
                 'page_title'=>"OAuth",
179 179
                 'site_title'=>config("app.name"),
180 180
                 'navigation'=>"OAuth",
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
                     ],
188 188
                 ]
189 189
             ]);
190
-        }else{
191
-            return view('oauth.index',[
190
+        } else {
191
+            return view('oauth.index', [
192 192
                 'page_title'=>"OAuth",
193 193
                 'site_title'=>config("app.name"),
194 194
                 'navigation'=>"OAuth",
Please login to merge, or discard this patch.