Completed
Push — master ( 96fd48...d1e399 )
by Patrick
03:37
created
LDAP/class.LDAPObject.php 1 patch
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,8 +16,14 @@
 block discarded – undo
16 16
          $ret = array();
17 17
          foreach ($this as $key => $value)
18 18
          {
19
-            if($key === 'server' || $key === 'count') continue;
20
-            if(is_numeric($key)) continue;
19
+            if($key === 'server' || $key === 'count')
20
+            {
21
+                continue;
22
+            }
23
+            if(is_numeric($key))
24
+            {
25
+                continue;
26
+            }
21 27
             if($key === 'jpegphoto')
22 28
             {
23 29
                 $ret[$key] = base64_encode($value[0]);
Please login to merge, or discard this patch.
class.FlipSession.php 1 patch
Braces   +7 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 require_once('Autoload.php');
3
-if(!isset($_SESSION) && php_sapi_name() !== 'cli') { session_start(); }
3
+if(!isset($_SESSION) && php_sapi_name() !== 'cli')
4
+{
5
+session_start(); }
4 6
 if(!isset($_SESSION['ip_address']) && isset($_SERVER['REMOTE_ADDR']))
5 7
 {
6 8
     $_SESSION['ip_address'] = $_SERVER['REMOTE_ADDR'];
@@ -156,7 +158,10 @@  discard block
 block discarded – undo
156 158
             $pos = strpos($sessionData, "|", $offset);
157 159
             $len = $pos - $offset;
158 160
             $name = substr($sessionData, $offset, $len);
159
-            if($name === false) break;
161
+            if($name === false)
162
+            {
163
+                break;
164
+            }
160 165
             $offset += $len+1;
161 166
             $data = @unserialize(substr($sessionData, $offset));
162 167
             $res[$name] = $data;
Please login to merge, or discard this patch.
Auth/class.Group.php 1 patch
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,10 @@
 block discarded – undo
90 90
                 {
91 91
                     $isLast = true;
92 92
                 }
93
-                if(!isset($group->member[$i]->type)) continue;
93
+                if(!isset($group->member[$i]->type))
94
+                {
95
+                    continue;
96
+                }
94 97
                 if($group->member[$i]->type === 'Group')
95 98
                 {
96 99
                     $this->addMember($group->member[$i]->cn, true, $isLast);
Please login to merge, or discard this patch.
Auth/class.SQLAuthenticator.php 1 patch
Braces   +21 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace Auth;
3 3
 
4
-if(!function_exists('password_hash') || !function_exists('password_verify')) 
4
+if(!function_exists('password_hash') || !function_exists('password_verify'))
5 5
 {
6 6
     define('PASSWORD_BCRYPT', 1);
7 7
     define('PASSWORD_DEFAULT', PASSWORD_BCRYPT);
@@ -149,7 +149,10 @@  discard block
 block discarded – undo
149 149
 
150 150
     public function login($username, $password)
151 151
     {
152
-        if($this->current === false) return false;
152
+        if($this->current === false)
153
+        {
154
+            return false;
155
+        }
153 156
         $userDataTable = $this->getDataTable('user');
154 157
         $filter = new \Data\Filter("uid eq '$username'");
155 158
         $users = $userDataTable->read($filter);
@@ -239,9 +242,15 @@  discard block
 block discarded – undo
239 242
 
240 243
     public function getPendingUserCount()
241 244
     {
242
-        if($this->pending === false) return 0;
245
+        if($this->pending === false)
246
+        {
247
+            return 0;
248
+        }
243 249
         $dataTable = $this->getPendingUserDataTable();
244
-        if($dataTable === null) return 0;
250
+        if($dataTable === null)
251
+        {
252
+            return 0;
253
+        }
245 254
         return $dataTable->count();
246 255
     }
247 256
 
@@ -278,7 +287,10 @@  discard block
 block discarded – undo
278 287
 
279 288
     public function getPendingUsersByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false)
280 289
     {
281
-        if($this->pending === false) return false;
290
+        if($this->pending === false)
291
+        {
292
+            return false;
293
+        }
282 294
         if($filter !== false && !$filter->contains('hash'))
283 295
         {
284 296
             return $this->searchPendingUsers($filter, $select, $top, $skip, $orderby);
@@ -299,7 +311,10 @@  discard block
 block discarded – undo
299 311
 
300 312
     public function createPendingUser($user)
301 313
     {
302
-        if($this->pending === false) return false;
314
+        if($this->pending === false)
315
+        {
316
+            return false;
317
+        }
303 318
         $userDataTable = $this->getPendingUserDataTable();
304 319
         if(isset($user->password2))
305 320
         {
Please login to merge, or discard this patch.
Auth/class.GoogleAuthenticator.php 1 patch
Braces   +35 added lines, -33 removed lines patch added patch discarded remove patch
@@ -2,20 +2,20 @@  discard block
 block discarded – undo
2 2
 namespace Auth;
3 3
 require dirname(__FILE__).'/../libs/google/src/Google/autoload.php';
4 4
 
5
-class GoogleAuthenticator extends Authenticator
6
-{
5
+class GoogleAuthenticator extends Authenticator
6
+{
7 7
     protected $client;
8 8
     protected $token = null;
9 9
 
10
-    public function __construct($params)
11
-    {
10
+    public function __construct($params)
11
+    {
12 12
         parent::__construct($params);
13
-        if(!isset($params['client_secrets_path']))
14
-        {
13
+        if(!isset($params['client_secrets_path']))
14
+        {
15 15
             throw new \Exception('Missing required parameter client_secrets_path!');
16 16
         }
17
-        if(!isset($params['redirect_url']))
18
-        {
17
+        if(!isset($params['redirect_url']))
18
+        {
19 19
             $params['redirect_url'] = 'https://'.$_SERVER['HTTP_HOST'].'/oauth2callback.php?src=google';
20 20
         }
21 21
         $this->token = \FlipSession::getVar('GoogleToken', null);
@@ -25,63 +25,64 @@  discard block
 block discarded – undo
25 25
         $this->client->setRedirectUri($params['redirect_url']);
26 26
     }
27 27
 
28
-    public function getSupplementLink()
29
-    {
28
+    public function getSupplementLink()
29
+    {
30 30
         $authUrl = $this->client->createAuthUrl();
31 31
         return '<a href="'.filter_var($authUrl, FILTER_SANITIZE_URL).'"><img src="/img/common/google_sign_in.png" style="width: 2em;"/></a>';
32 32
     }
33 33
 
34
-    public function authenticate($code, &$currentUser = false)
35
-    {
34
+    public function authenticate($code, &$currentUser = false)
35
+    {
36 36
         $googleUser = false;
37
-        try
38
-        {
37
+        try
38
+        {
39 39
             $this->client->authenticate($code);
40 40
             $this->token = $this->client->getAccessToken();
41 41
             \FlipSession::setVar('GoogleToken', $this->token);
42 42
             $oauth2Service = new \Google_Service_Oauth2($this->client);
43 43
             $googleUser = $oauth2Service->userinfo->get();
44
-        }
45
-        catch(\Exception $ex)
46
-        {
44
+        }
45
+        catch(\Exception $ex)
46
+        {
47 47
             return self::LOGIN_FAILED;
48 48
         }
49 49
 
50 50
         $auth = \AuthProvider::getInstance();
51 51
         $localUsers = $auth->getUsersByFilter(new \Data\Filter('mail eq '.$googleUser->email));
52
-        if($localUsers !== false && isset($localUsers[0]))
53
-        {
54
-            if($localUsers[0]->canLoginWith('google.com'))
55
-            {
52
+        if($localUsers !== false && isset($localUsers[0]))
53
+        {
54
+            if($localUsers[0]->canLoginWith('google.com'))
55
+            {
56 56
                 $auth->impersonateUser($localUsers[0]);
57 57
                 return self::SUCCESS;
58 58
             }
59 59
             $currentUser = $localUsers[0];
60 60
             return self::ALREADY_PRESENT;
61
-        }
62
-        else
63
-        {
61
+        }
62
+        else
63
+        {
64 64
             $user = new PendingUser();
65 65
             $user->setEmail($googleUser->email);
66 66
             $user->setGivenName($googleUser->givenName);
67 67
             $user->setLastName($googleUser->familyName);
68 68
             $user->addLoginProvider('google.com');
69 69
             $ret = $auth->activatePendingUser($user);
70
-            if($ret === false)
71
-            {
70
+            if($ret === false)
71
+            {
72 72
                  throw new \Exception('Unable to create user! '.$res);
73 73
             }
74 74
             return self::SUCCESS;
75 75
         }
76 76
     }
77 77
 
78
-    public function getUser($data = false)
79
-    {
80
-        if($data === false)
81
-        {
78
+    public function getUser($data = false)
79
+    {
80
+        if($data === false)
81
+        {
82 82
             $data = $this->token;
83 83
         }
84
-        try {
84
+        try
85
+        {
85 86
             $this->client->setAccessToken($data);
86 87
             $oauth2Service = new \Google_Service_Oauth2($this->client);
87 88
             $googleUser = $oauth2Service->userinfo->get();
@@ -92,8 +93,9 @@  discard block
 block discarded – undo
92 93
             $profileUser['displayName'] = $googleUser->name;
93 94
             $profileUser['jpegPhoto'] = base64_encode(file_get_contents($googleUser->picture));
94 95
             return $profileUser;
95
-        } catch(\Exception $e)
96
-        {
96
+        }
97
+        catch(\Exception $e)
98
+        {
97 99
             return false;
98 100
         }
99 101
     }
Please login to merge, or discard this patch.