@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * @var null |
9 | 9 | */ |
10 | - public $credentialHash=null; |
|
10 | + public $credentialHash = null; |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * @return string |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | // the absolute params property must be present |
18 | 18 | // in the object and the params value must be the builder key. |
19 | - if(property_exists($this,'params') and isset($this->params['builder'])){ |
|
19 | + if (property_exists($this, 'params') and isset($this->params['builder'])) { |
|
20 | 20 | |
21 | 21 | // a real token will be generated after |
22 | 22 | // you get the first method of the query builder value. |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | // we refer to the token closure feature on the config to enable |
26 | 26 | // the creation of user-based tokens on the application side. |
27 | - return $this->getTokenFromProvider($authData,function() use($authData){ |
|
27 | + return $this->getTokenFromProvider($authData, function() use($authData){ |
|
28 | 28 | return md5(sha1($authData->id.'__'.$this->credentialHash.'__'.time().'__'.fingerPrint())); |
29 | 29 | }); |
30 | 30 | } |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | * @param callable $callback |
38 | 38 | * @return mixed |
39 | 39 | */ |
40 | - private function getTokenFromProvider($authData,callable $callback) |
|
40 | + private function getTokenFromProvider($authData, callable $callback) |
|
41 | 41 | { |
42 | 42 | // if the token value is a closure value, |
43 | 43 | // we will run a user-based token closure. |
44 | - if(app()->has('authenticate.token') && is_callable($token = app()->get('authenticate.token'))){ |
|
44 | + if (app()->has('authenticate.token') && is_callable($token = app()->get('authenticate.token'))) { |
|
45 | 45 | return $token($authData); |
46 | 46 | } |
47 | 47 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | { |
36 | 36 | $userId = $manager->getAuth()->params['userId']; |
37 | 37 | |
38 | - return DeviceToken::where('user_id',$userId)->get(); |
|
38 | + return DeviceToken::where('user_id', $userId)->get(); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | protected function callbackQueryWithoutCredentials($driver) |
46 | 46 | { |
47 | - if($this->isCallableAddToWhere()){ |
|
47 | + if ($this->isCallableAddToWhere()) { |
|
48 | 48 | |
49 | 49 | return $driver::where(function($query) { |
50 | 50 | |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | return DeviceToken::where(function($query) use($token) { |
67 | 67 | |
68 | 68 | //where query for token |
69 | - $query->where('token_integer',crc32(md5($token))); |
|
70 | - $query->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT']))); |
|
69 | + $query->where('token_integer', crc32(md5($token))); |
|
70 | + $query->where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT']))); |
|
71 | 71 | |
72 | 72 | // if the addToWhereClosure value is a closure, |
73 | 73 | // then in this case we actually run |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | return DeviceToken::where(function($query) use($token) { |
97 | 97 | |
98 | 98 | //where query for token |
99 | - $query->where('token_integer',crc32(md5($token))); |
|
100 | - $query->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT']))); |
|
99 | + $query->where('token_integer', crc32(md5($token))); |
|
100 | + $query->where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT']))); |
|
101 | 101 | |
102 | 102 | // if the addToWhereClosure value is a closure, |
103 | 103 | // then in this case we actually run |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | * @param array $credentials |
115 | 115 | * @return mixed |
116 | 116 | */ |
117 | - protected function queryAddToWhere($query,$credentials=array()) |
|
117 | + protected function queryAddToWhere($query, $credentials = array()) |
|
118 | 118 | { |
119 | 119 | // if the addToWhereClosure value is a closure, |
120 | 120 | // then in this case we actually run |
121 | 121 | // the closure object and add it to the query value. |
122 | - if($this->isCallableAddToWhere()){ |
|
123 | - return $this->query['addToWhere']($query,$credentials); |
|
122 | + if ($this->isCallableAddToWhere()) { |
|
123 | + return $this->query['addToWhere']($query, $credentials); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | //we get the model specified for the builder. |
136 | 136 | $driver = $this->query['driver']; |
137 | 137 | |
138 | - if(count($credentials->get())==0){ |
|
138 | + if (count($credentials->get())==0) { |
|
139 | 139 | |
140 | 140 | // if the credential array is empty in the config section, |
141 | 141 | // then you must run the query with a callable value of addToWhere value. |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | |
149 | 149 | // with the callback method (eloquent model) |
150 | 150 | // we write the where clause. |
151 | - foreach ($credentials->get() as $credential=>$credentialValue){ |
|
151 | + foreach ($credentials->get() as $credential=>$credentialValue) { |
|
152 | 152 | |
153 | - if(app()->has('authenticate.'.$credential) |
|
154 | - && is_callable($provider = app()->get('authenticate.'.$credential))){ |
|
155 | - $query->where($credential,$provider($credentialValue)); |
|
153 | + if (app()->has('authenticate.'.$credential) |
|
154 | + && is_callable($provider = app()->get('authenticate.'.$credential))) { |
|
155 | + $query->where($credential, $provider($credentialValue)); |
|
156 | 156 | } |
157 | - else{ |
|
158 | - $query->where($credential,$credentialValue); |
|
157 | + else { |
|
158 | + $query->where($credential, $credentialValue); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | } |
@@ -163,17 +163,17 @@ discard block |
||
163 | 163 | // if the addToWhereClosure value is a closure, |
164 | 164 | // then in this case we actually run |
165 | 165 | // the closure object and add it to the query value. |
166 | - $this->queryAddToWhere($query,$credentials->get(),$credentials->get()); |
|
166 | + $this->queryAddToWhere($query, $credentials->get(), $credentials->get()); |
|
167 | 167 | }); |
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
171 | 171 | * @return void|mixed |
172 | 172 | */ |
173 | - protected function updateToken($token=null) |
|
173 | + protected function updateToken($token = null) |
|
174 | 174 | { |
175 | 175 | //if query status value is true |
176 | - if($this->auth->params['status']){ |
|
176 | + if ($this->auth->params['status']) { |
|
177 | 177 | |
178 | 178 | // we go to the method that produces |
179 | 179 | // the classical token value and get the token value. |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | // if there is no update, we reset the status value to 0. |
184 | 184 | $update = $this->auth->params['builder']->update(['token'=>$this->auth->params['token']]); |
185 | 185 | |
186 | - if(!$update){ |
|
186 | + if (!$update) { |
|
187 | 187 | $this->auth->params['status'] = 0; |
188 | 188 | $this->auth->params['exception'] = 'update'; |
189 | 189 | } |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | { |
200 | 200 | $token_integer = crc32(md5($this->auth->params['token'])); |
201 | 201 | |
202 | - if(!is_null($token_integer)){ |
|
202 | + if (!is_null($token_integer)) { |
|
203 | 203 | |
204 | - if(DeviceToken::where('user_id',$this->auth->params['authId']) |
|
205 | - ->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT'])))->count()==0){ |
|
204 | + if (DeviceToken::where('user_id', $this->auth->params['authId']) |
|
205 | + ->where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT'])))->count()==0) { |
|
206 | 206 | |
207 | 207 | return DeviceToken::create([ |
208 | 208 | 'user_id' => $this->auth->params['authId'], |
@@ -213,10 +213,10 @@ discard block |
||
213 | 213 | 'expire' => $this->auth->getExpire(), |
214 | 214 | ]); |
215 | 215 | } |
216 | - else{ |
|
216 | + else { |
|
217 | 217 | |
218 | - return DeviceToken::where('user_id',$this->auth->params['authId']) |
|
219 | - ->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT']))) |
|
218 | + return DeviceToken::where('user_id', $this->auth->params['authId']) |
|
219 | + ->where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT']))) |
|
220 | 220 | ->update([ |
221 | 221 | 'token' => $this->auth->params['token'], |
222 | 222 | 'token_integer' => $token_integer |
@@ -236,11 +236,11 @@ discard block |
||
236 | 236 | { |
237 | 237 | $token_integer = crc32(md5($this->auth->getTokenSentByUser())); |
238 | 238 | |
239 | - if(!is_null($token_integer)){ |
|
239 | + if (!is_null($token_integer)) { |
|
240 | 240 | |
241 | - DeviceToken::where('token_integer',$token_integer)->delete(); |
|
241 | + DeviceToken::where('token_integer', $token_integer)->delete(); |
|
242 | 242 | |
243 | - return (DeviceToken::where('token_integer',$token_integer)->count()) ? false : true; |
|
243 | + return (DeviceToken::where('token_integer', $token_integer)->count()) ? false : true; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | } |
@@ -153,8 +153,7 @@ discard block |
||
153 | 153 | if(app()->has('authenticate.'.$credential) |
154 | 154 | && is_callable($provider = app()->get('authenticate.'.$credential))){ |
155 | 155 | $query->where($credential,$provider($credentialValue)); |
156 | - } |
|
157 | - else{ |
|
156 | + } else{ |
|
158 | 157 | $query->where($credential,$credentialValue); |
159 | 158 | } |
160 | 159 | |
@@ -212,8 +211,7 @@ discard block |
||
212 | 211 | 'device_agent_integer' => crc32(md5($_SERVER['HTTP_USER_AGENT'])), |
213 | 212 | 'expire' => $this->auth->getExpire(), |
214 | 213 | ]); |
215 | - } |
|
216 | - else{ |
|
214 | + } else{ |
|
217 | 215 | |
218 | 216 | return DeviceToken::where('user_id',$this->auth->params['authId']) |
219 | 217 | ->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT']))) |