Completed
Pull Request — master (#6)
by Patrick
03:39
created
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.
LDAP/class.LDAPObject.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -3,19 +3,19 @@  discard block
 block discarded – undo
3 3
 
4 4
 class LDAPObject extends \SerializableObject
5 5
 {
6
-     public $server;
6
+        public $server;
7 7
 
8
-     function __construct($array = false, $server = false)
9
-     {
10
-         parent::__construct($array);
11
-         $this->server = $server;
12
-     }
8
+        function __construct($array = false, $server = false)
9
+        {
10
+            parent::__construct($array);
11
+            $this->server = $server;
12
+        }
13 13
 
14
-     public function jsonSerialize()
15
-     {
16
-         $ret = array();
17
-         foreach($this as $key => $value)
18
-         {
14
+        public function jsonSerialize()
15
+        {
16
+            $ret = array();
17
+            foreach($this as $key => $value)
18
+            {
19 19
             if($key === 'server' || $key === 'count') continue;
20 20
             if(is_numeric($key)) continue;
21 21
             if($key === 'jpegphoto')
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
             {
32 32
                 $ret[$key] = $value;
33 33
             }
34
-         }
35
-         return $ret;
36
-     }
34
+            }
35
+            return $ret;
36
+        }
37 37
 }
38 38
 
39 39
 ?>
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.