@@ -44,7 +44,7 @@ |
||
44 | 44 | $this->credentials = $credentials; |
45 | 45 | |
46 | 46 | //credentials loop for expected property |
47 | - foreach ($this->credentials->get() as $credential){ |
|
47 | + foreach ($this->credentials->get() as $credential) { |
|
48 | 48 | $this->expected[] = $credential; |
49 | 49 | } |
50 | 50 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | // if the status value is true, |
26 | 26 | // we send output generated from the token value. |
27 | - if($this->checkStatus()){ |
|
27 | + if ($this->checkStatus()) { |
|
28 | 28 | return true; |
29 | 29 | } |
30 | 30 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | { |
40 | 40 | // if the status value is true, |
41 | 41 | // we send output generated from the token value. |
42 | - if($this->checkStatus()){ |
|
42 | + if ($this->checkStatus()) { |
|
43 | 43 | return true; |
44 | 44 | } |
45 | 45 | |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | */ |
53 | 53 | protected function getResult() |
54 | 54 | { |
55 | - $result= []; |
|
55 | + $result = []; |
|
56 | 56 | |
57 | 57 | // if the status value is true, |
58 | 58 | // we send output generated from the token value. |
59 | - if($this->checkStatus()){ |
|
59 | + if ($this->checkStatus()) { |
|
60 | 60 | $result['message'] = 'token success'; |
61 | 61 | $result['token'] = $this->params['token']; |
62 | 62 |
@@ -44,7 +44,7 @@ |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | //logout exception |
47 | - $this->{$this->params['exception']}(); |
|
47 | + $this->{$this->params['exception']}(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -13,5 +13,5 @@ |
||
13 | 13 | /** |
14 | 14 | * @var array |
15 | 15 | */ |
16 | - protected $fillable = ['user_id','token','token_integer','device_agent','device_agent_integer','expire']; |
|
16 | + protected $fillable = ['user_id', 'token', 'token_integer', 'device_agent', 'device_agent_integer', 'expire']; |
|
17 | 17 | } |
@@ -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->tokenForConfig($authData,function() use($authData){ |
|
27 | + return $this->tokenForConfig($authData, function() use($authData){ |
|
28 | 28 | return md5(sha1($authData->id.'__'.$this->credentialHash.'__'.time().'__'.fingerPrint())); |
29 | 29 | }); |
30 | 30 | } |
@@ -37,15 +37,15 @@ discard block |
||
37 | 37 | * @param callable $callback |
38 | 38 | * @return mixed |
39 | 39 | */ |
40 | - private function tokenForConfig($authData,callable $callback) |
|
40 | + private function tokenForConfig($authData, callable $callback) |
|
41 | 41 | { |
42 | 42 | // we get the authenticate token value |
43 | 43 | // from the config values. |
44 | - $configToken=$this->getConfigToken(); |
|
44 | + $configToken = $this->getConfigToken(); |
|
45 | 45 | |
46 | 46 | // if the token value is a closure value, |
47 | 47 | // we will run a user-based token closure. |
48 | - if(is_callable($configToken)){ |
|
48 | + if (is_callable($configToken)) { |
|
49 | 49 | return $configToken($authData); |
50 | 50 | } |
51 | 51 |
@@ -14,7 +14,7 @@ |
||
14 | 14 | * @param $auth |
15 | 15 | * @param $token |
16 | 16 | */ |
17 | - public function __construct($auth,$token) |
|
17 | + public function __construct($auth, $token) |
|
18 | 18 | { |
19 | 19 | parent::__construct($auth); |
20 | 20 |
@@ -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. |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | // |
146 | - if($this->isCallableAddToWhere()){ |
|
147 | - return $this->queryAddToWhere($driver,$credentials->get()); |
|
146 | + if ($this->isCallableAddToWhere()) { |
|
147 | + return $this->queryAddToWhere($driver, $credentials->get()); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | // using the driver object we write the query builder statement. |
@@ -153,24 +153,24 @@ discard block |
||
153 | 153 | |
154 | 154 | // with the callback method (eloquent model) |
155 | 155 | // we write the where clause. |
156 | - foreach ($credentials->get() as $credential=>$credentialValue){ |
|
157 | - $query->where($credential,$credentialValue); |
|
156 | + foreach ($credentials->get() as $credential=>$credentialValue) { |
|
157 | + $query->where($credential, $credentialValue); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | // if the addToWhereClosure value is a closure, |
161 | 161 | // then in this case we actually run |
162 | 162 | // the closure object and add it to the query value. |
163 | - $this->queryAddToWhere($query,$credentials->get(),$credentials->get()); |
|
163 | + $this->queryAddToWhere($query, $credentials->get(), $credentials->get()); |
|
164 | 164 | }); |
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
168 | 168 | * @return void|mixed |
169 | 169 | */ |
170 | - protected function updateToken($token=null) |
|
170 | + protected function updateToken($token = null) |
|
171 | 171 | { |
172 | 172 | //if query status value is true |
173 | - if($this->auth->params['status']){ |
|
173 | + if ($this->auth->params['status']) { |
|
174 | 174 | |
175 | 175 | // we go to the method that produces |
176 | 176 | // the classical token value and get the token value. |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | // if there is no update, we reset the status value to 0. |
181 | 181 | $update = $this->auth->params['builder']->update(['token'=>$this->auth->params['token']]); |
182 | 182 | |
183 | - if(!$update){ |
|
183 | + if (!$update) { |
|
184 | 184 | $this->auth->params['status'] = 0; |
185 | 185 | $this->auth->params['exception'] = 'update'; |
186 | 186 | } |
@@ -196,10 +196,10 @@ discard block |
||
196 | 196 | { |
197 | 197 | $token_integer = crc32(md5($this->auth->params['token'])); |
198 | 198 | |
199 | - if(!is_null($token_integer)){ |
|
199 | + if (!is_null($token_integer)) { |
|
200 | 200 | |
201 | - if(DeviceToken::where('user_id',$this->auth->params['authId']) |
|
202 | - ->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT'])))->count()==0){ |
|
201 | + if (DeviceToken::where('user_id', $this->auth->params['authId']) |
|
202 | + ->where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT'])))->count()==0) { |
|
203 | 203 | |
204 | 204 | return DeviceToken::create([ |
205 | 205 | 'user_id' => $this->auth->params['authId'], |
@@ -210,10 +210,10 @@ discard block |
||
210 | 210 | 'expire' => $this->auth->getExpire(), |
211 | 211 | ]); |
212 | 212 | } |
213 | - else{ |
|
213 | + else { |
|
214 | 214 | |
215 | - return DeviceToken::where('user_id',$this->auth->params['authId']) |
|
216 | - ->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT']))) |
|
215 | + return DeviceToken::where('user_id', $this->auth->params['authId']) |
|
216 | + ->where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT']))) |
|
217 | 217 | ->update([ |
218 | 218 | 'token' => $this->auth->params['token'], |
219 | 219 | 'token_integer' => $token_integer |
@@ -233,11 +233,11 @@ discard block |
||
233 | 233 | { |
234 | 234 | $token_integer = crc32(md5($this->auth->getTokenSentByUser())); |
235 | 235 | |
236 | - if(!is_null($token_integer)){ |
|
236 | + if (!is_null($token_integer)) { |
|
237 | 237 | |
238 | - DeviceToken::where('token_integer',$token_integer)->delete(); |
|
238 | + DeviceToken::where('token_integer', $token_integer)->delete(); |
|
239 | 239 | |
240 | - return (DeviceToken::where('token_integer',$token_integer)->count()) ? false : true; |
|
240 | + return (DeviceToken::where('token_integer', $token_integer)->count()) ? false : true; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | } |
@@ -209,8 +209,7 @@ |
||
209 | 209 | 'device_agent_integer' => crc32(md5($_SERVER['HTTP_USER_AGENT'])), |
210 | 210 | 'expire' => $this->auth->getExpire(), |
211 | 211 | ]); |
212 | - } |
|
213 | - else{ |
|
212 | + } else{ |
|
214 | 213 | |
215 | 214 | return DeviceToken::where('user_id',$this->auth->params['authId']) |
216 | 215 | ->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT']))) |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | // with query we bind the returned values to the params property of the auth object. |
54 | 54 | // and so the auth object will make a final return with these values. |
55 | - $this->paramValues('check',$query); |
|
55 | + $this->paramValues('check', $query); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | // with query we bind the returned values to the params property of the auth object. |
71 | 71 | // and so the auth object will make a final return with these values. |
72 | - $this->paramValues('login',$query); |
|
72 | + $this->paramValues('login', $query); |
|
73 | 73 | |
74 | 74 | // we assign the credential hash value |
75 | 75 | // to the global of the authenticate object. |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | // we update the token value. |
80 | 80 | $this->updateToken(); |
81 | 81 | |
82 | - if(isset($this->auth->params['authToken'])){ |
|
82 | + if (isset($this->auth->params['authToken'])) { |
|
83 | 83 | $this->saveDeviceToken(); |
84 | 84 | } |
85 | 85 | } |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | |
98 | 98 | // with query we bind the returned values to the params property of the auth object. |
99 | 99 | // and so the auth object will make a final return with these values. |
100 | - $this->paramValues('logout',$query); |
|
100 | + $this->paramValues('logout', $query); |
|
101 | 101 | |
102 | 102 | //token updating as null |
103 | - if(isset($this->auth->params['authToken'])){ |
|
104 | - if(!$this->deleteDeviceToken()){ |
|
103 | + if (isset($this->auth->params['authToken'])) { |
|
104 | + if (!$this->deleteDeviceToken()) { |
|
105 | 105 | $this->auth->params['status'] = 0; |
106 | 106 | $this->auth->params['exception'] = 'logoutInternal'; |
107 | 107 | return false; |
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
111 | - if($this->auth->params['status']===0){ |
|
111 | + if ($this->auth->params['status']===0) { |
|
112 | 112 | $this->auth->params['exception'] = 'logoutException'; |
113 | 113 | } |
114 | 114 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | * @param $deviceTokenId |
12 | 12 | * @param AuthenticateProvider $auth |
13 | 13 | */ |
14 | - public function __construct($deviceTokenId,$auth) |
|
14 | + public function __construct($deviceTokenId, $auth) |
|
15 | 15 | { |
16 | 16 | parent::__construct($auth); |
17 | 17 |
@@ -9,21 +9,21 @@ discard block |
||
9 | 9 | * @param callable|null $callback |
10 | 10 | * @return mixed|null |
11 | 11 | */ |
12 | - protected function checkParamsViaAvailability($data,callable $callback=null) |
|
12 | + protected function checkParamsViaAvailability($data, callable $callback = null) |
|
13 | 13 | { |
14 | - if(is_callable($data) && is_null($callback)){ |
|
14 | + if (is_callable($data) && is_null($callback)) { |
|
15 | 15 | |
16 | 16 | // if an authenticate is provided via the existing check method, |
17 | 17 | // then we return the value of the data that we are checking for with callback help. |
18 | - if($this->check()){ |
|
18 | + if ($this->check()) { |
|
19 | 19 | return call_user_func($data); |
20 | 20 | } |
21 | 21 | } |
22 | 22 | |
23 | 23 | // if an authenticate is provided via the existing check method, |
24 | 24 | // then we return the value of the data that we are checking for with callback help. |
25 | - if($this->check() && isset($this->params[$data])){ |
|
26 | - return call_user_func_array($callback,[$this->params[$data]]); |
|
25 | + if ($this->check() && isset($this->params[$data])) { |
|
26 | + return call_user_func_array($callback, [$this->params[$data]]); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | return null; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | // we will determine whether |
40 | 40 | // the http path is correct for this method. |
41 | - if(isset($getHttp[$type]) and $getHttp[$type]!==httpMethod()){ |
|
41 | + if (isset($getHttp[$type]) and $getHttp[$type]!==httpMethod()) { |
|
42 | 42 | $this->getExceptionForHttp($getHttp[$type]); |
43 | 43 | } |
44 | 44 | } |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | { |
51 | 51 | // if there is a token in the headers, |
52 | 52 | // we return the callback. |
53 | - if(!is_null($this->getTokenSentByUser())){ |
|
54 | - return call_user_func_array($callback,[$this->getTokenSentByUser()]); |
|
53 | + if (!is_null($this->getTokenSentByUser())) { |
|
54 | + return call_user_func_array($callback, [$this->getTokenSentByUser()]); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | //token false |