@@ -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 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | protected function callbackQueryWithoutCredentials($driver) |
32 | 32 | { |
33 | - if($this->isCallableAddToWhere()){ |
|
33 | + if ($this->isCallableAddToWhere()) { |
|
34 | 34 | |
35 | 35 | return $driver::where(function($query) { |
36 | 36 | |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | return DeviceToken::where(function($query) use($token) { |
53 | 53 | |
54 | 54 | //where query for token |
55 | - $query->where('token_integer',crc32(md5($token))); |
|
56 | - $query->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT']))); |
|
55 | + $query->where('token_integer', crc32(md5($token))); |
|
56 | + $query->where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT']))); |
|
57 | 57 | |
58 | 58 | // if the addToWhereClosure value is a closure, |
59 | 59 | // then in this case we actually run |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | protected function logoutQuery($token) |
80 | 80 | { |
81 | 81 | //we get the model specified for the builder. |
82 | - $driver=$this->query['driver']; |
|
82 | + $driver = $this->query['driver']; |
|
83 | 83 | |
84 | 84 | //token query for builder |
85 | - $query=$driver::where(function($query) use($token) { |
|
85 | + $query = $driver::where(function($query) use($token) { |
|
86 | 86 | |
87 | 87 | //where query for token |
88 | - $query->where('token',$token); |
|
88 | + $query->where('token', $token); |
|
89 | 89 | |
90 | 90 | // if the addToWhereClosure value is a closure, |
91 | 91 | // then in this case we actually run |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | * @param array $credentials |
105 | 105 | * @return mixed |
106 | 106 | */ |
107 | - protected function queryAddToWhere($query,$credentials=array()) |
|
107 | + protected function queryAddToWhere($query, $credentials = array()) |
|
108 | 108 | { |
109 | 109 | // if the addToWhereClosure value is a closure, |
110 | 110 | // then in this case we actually run |
111 | 111 | // the closure object and add it to the query value. |
112 | - if($this->isCallableAddToWhere()){ |
|
113 | - return $this->query['addToWhere']($query,$credentials); |
|
112 | + if ($this->isCallableAddToWhere()) { |
|
113 | + return $this->query['addToWhere']($query, $credentials); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | //we get the model specified for the builder. |
126 | 126 | $driver = $this->query['driver']; |
127 | 127 | |
128 | - if(count($credentials->get())==0){ |
|
128 | + if (count($credentials->get())==0) { |
|
129 | 129 | |
130 | 130 | // if the credential array is empty in the config section, |
131 | 131 | // then you must run the query with a callable value of addToWhere value. |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | // |
136 | - if($this->isCallableAddToWhere()){ |
|
137 | - return $this->queryAddToWhere($driver,$credentials->get()); |
|
136 | + if ($this->isCallableAddToWhere()) { |
|
137 | + return $this->queryAddToWhere($driver, $credentials->get()); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | // using the driver object we write the query builder statement. |
@@ -143,24 +143,24 @@ discard block |
||
143 | 143 | |
144 | 144 | // with the callback method (eloquent model) |
145 | 145 | // we write the where clause. |
146 | - foreach ($credentials->get() as $credential=>$credentialValue){ |
|
147 | - $query->where($credential,$credentialValue); |
|
146 | + foreach ($credentials->get() as $credential=>$credentialValue) { |
|
147 | + $query->where($credential, $credentialValue); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | // if the addToWhereClosure value is a closure, |
151 | 151 | // then in this case we actually run |
152 | 152 | // the closure object and add it to the query value. |
153 | - $this->queryAddToWhere($query,$credentials->get(),$credentials->get()); |
|
153 | + $this->queryAddToWhere($query, $credentials->get(), $credentials->get()); |
|
154 | 154 | }); |
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
158 | 158 | * @return void|mixed |
159 | 159 | */ |
160 | - protected function updateToken($token=null) |
|
160 | + protected function updateToken($token = null) |
|
161 | 161 | { |
162 | 162 | //if query status value is true |
163 | - if($this->auth->params['status']){ |
|
163 | + if ($this->auth->params['status']) { |
|
164 | 164 | |
165 | 165 | // we go to the method that produces |
166 | 166 | // the classical token value and get the token value. |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | // if there is no update, we reset the status value to 0. |
171 | 171 | $update = $this->auth->params['builder']->update(['token'=>$this->auth->params['token']]); |
172 | 172 | |
173 | - if(!$update){ |
|
173 | + if (!$update) { |
|
174 | 174 | $this->auth->params['status'] = 0; |
175 | 175 | $this->auth->params['exception'] = 'update'; |
176 | 176 | } |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | { |
187 | 187 | $token_integer = crc32(md5($this->auth->params['token'])); |
188 | 188 | |
189 | - if(!is_null($token_integer)){ |
|
189 | + if (!is_null($token_integer)) { |
|
190 | 190 | |
191 | - if(DeviceToken::where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT'])))->count()==0){ |
|
191 | + if (DeviceToken::where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT'])))->count()==0) { |
|
192 | 192 | return DeviceToken::create([ |
193 | 193 | 'user_id' => $this->auth->params['authId'], |
194 | 194 | 'token' => $this->auth->params['token'], |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | 'expire' => 0 |
199 | 199 | ]); |
200 | 200 | } |
201 | - else{ |
|
201 | + else { |
|
202 | 202 | |
203 | - return DeviceToken::where('user_id',$this->auth->params['authId']) |
|
204 | - ->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT']))) |
|
203 | + return DeviceToken::where('user_id', $this->auth->params['authId']) |
|
204 | + ->where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT']))) |
|
205 | 205 | ->update([ |
206 | 206 | 'token' => $this->auth->params['token'], |
207 | 207 | 'token_integer' => $token_integer |
@@ -197,8 +197,7 @@ |
||
197 | 197 | 'device_agent_integer' => crc32(md5($_SERVER['HTTP_USER_AGENT'])), |
198 | 198 | 'expire' => 0 |
199 | 199 | ]); |
200 | - } |
|
201 | - else{ |
|
200 | + } else{ |
|
202 | 201 | |
203 | 202 | return DeviceToken::where('user_id',$this->auth->params['authId']) |
204 | 203 | ->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT']))) |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | // with query we bind the returned values to the params property of the auth object. |
43 | 43 | // and so the auth object will make a final return with these values. |
44 | - $this->paramValues('check',$query); |
|
44 | + $this->paramValues('check', $query); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | // with query we bind the returned values to the params property of the auth object. |
60 | 60 | // and so the auth object will make a final return with these values. |
61 | - $this->paramValues('login',$query); |
|
61 | + $this->paramValues('login', $query); |
|
62 | 62 | |
63 | 63 | // we assign the credential hash value |
64 | 64 | // to the global of the authenticate object. |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | // we update the token value. |
69 | 69 | $this->updateToken(); |
70 | 70 | |
71 | - if(isset($this->auth->params['authToken'])){ |
|
71 | + if (isset($this->auth->params['authToken'])) { |
|
72 | 72 | $this->saveDeviceToken(); |
73 | 73 | } |
74 | 74 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | // with query we bind the returned values to the params property of the auth object. |
88 | 88 | // and so the auth object will make a final return with these values. |
89 | - $this->paramValues('logout',$query); |
|
89 | + $this->paramValues('logout', $query); |
|
90 | 90 | |
91 | 91 | //token updating as null |
92 | 92 | $this->updateToken(md5(time())); |
@@ -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 |