@@ -14,31 +14,31 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @var null |
16 | 16 | */ |
17 | - protected $credentialHash=null; |
|
17 | + protected $credentialHash = null; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @var $request |
21 | 21 | */ |
22 | - protected $request=null; |
|
22 | + protected $request = null; |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * AuthLoginCredentialsManager constructor. |
26 | 26 | * @param $credentials |
27 | 27 | * @param bool $using |
28 | 28 | */ |
29 | - public function __construct($credentials,$using=false) |
|
29 | + public function __construct($credentials, $using = false) |
|
30 | 30 | { |
31 | 31 | //get credentials as default |
32 | - $this->credentials=$credentials; |
|
32 | + $this->credentials = $credentials; |
|
33 | 33 | |
34 | 34 | //get credential hash |
35 | 35 | $this->setCredentialHash(); |
36 | 36 | |
37 | - if($using===false){ |
|
37 | + if ($using===false) { |
|
38 | 38 | |
39 | 39 | // the request object will help you process |
40 | 40 | // the credentials and get them correctly. |
41 | - $this->request=new AuthenticateRequest($this->credentials); |
|
41 | + $this->request = new AuthenticateRequest($this->credentials); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | //request handle |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | { |
71 | 71 | // with the request object we get |
72 | 72 | // the credentials values through the all method. |
73 | - $this->credentials=($this->request===null) ? $this->get() : $this->request->credentials($this->credentials); |
|
73 | + $this->credentials = ($this->request===null) ? $this->get() : $this->request->credentials($this->credentials); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | private function setCredentialHash() |
80 | 80 | { |
81 | 81 | //set credential hash |
82 | - if(count($this->credentials)){ |
|
83 | - $this->credentialHash=md5(sha1(implode("|",$this->credentials))); |
|
82 | + if (count($this->credentials)) { |
|
83 | + $this->credentialHash = md5(sha1(implode("|", $this->credentials))); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | } |
87 | 87 | \ No newline at end of file |
@@ -14,12 +14,12 @@ |
||
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 | |
21 | 21 | //token value received by client |
22 | - $this->token=$token; |
|
22 | + $this->token = $token; |
|
23 | 23 | |
24 | 24 | //query check |
25 | 25 | $this->checkProcess(); |
@@ -14,12 +14,12 @@ |
||
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 | |
21 | 21 | //token value received by client |
22 | - $this->token=$token; |
|
22 | + $this->token = $token; |
|
23 | 23 | |
24 | 24 | //query check |
25 | 25 | $this->logoutProcess(); |
@@ -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,15 +16,15 @@ 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. |
23 | - $authData=$this->params['data']; |
|
23 | + $authData = $this->params['data']; |
|
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 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public function __construct($auth) |
23 | 23 | { |
24 | 24 | //authenticate instance |
25 | - $this->auth=$auth; |
|
25 | + $this->auth = $auth; |
|
26 | 26 | |
27 | 27 | parent::__construct(); |
28 | 28 | } |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | { |
35 | 35 | // using the driver object we write the query builder statement. |
36 | 36 | // we do the values of the query with the token that are sent. |
37 | - $query=$this->checkQuery($token); |
|
37 | + $query = $this->checkQuery($token); |
|
38 | 38 | |
39 | 39 | // with query we bind the returned values to the params property of the auth object. |
40 | 40 | // and so the auth object will make a final return with these values. |
41 | - $this->paramValues('check',$query); |
|
41 | + $this->paramValues('check', $query); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -49,15 +49,15 @@ discard block |
||
49 | 49 | { |
50 | 50 | // using the driver object we write the query builder statement. |
51 | 51 | // we do the values of the query with the credentials that are sent. |
52 | - $query=$this->setQuery($credentials); |
|
52 | + $query = $this->setQuery($credentials); |
|
53 | 53 | |
54 | 54 | // with query we bind the returned values to the params property of the auth object. |
55 | 55 | // and so the auth object will make a final return with these values. |
56 | - $this->paramValues('login',$query); |
|
56 | + $this->paramValues('login', $query); |
|
57 | 57 | |
58 | 58 | // we assign the credential hash value |
59 | 59 | // to the global of the authenticate object. |
60 | - $this->auth->credentialHash=$credentials->getCredentialHash(); |
|
60 | + $this->auth->credentialHash = $credentials->getCredentialHash(); |
|
61 | 61 | |
62 | 62 | // when the query succeeds, |
63 | 63 | // we update the token value. |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | { |
72 | 72 | // using the driver object we write the query builder statement. |
73 | 73 | // we do the values of the query with the token that are sent. |
74 | - $query=$this->logoutQuery($token); |
|
74 | + $query = $this->logoutQuery($token); |
|
75 | 75 | |
76 | 76 | // with query we bind the returned values to the params property of the auth object. |
77 | 77 | // and so the auth object will make a final return with these values. |
78 | - $this->paramValues('logout',$query); |
|
78 | + $this->paramValues('logout', $query); |
|
79 | 79 | |
80 | 80 | //token updating as null |
81 | 81 | $this->updateToken(md5(time())); |
@@ -8,5 +8,5 @@ |
||
8 | 8 | /** |
9 | 9 | * @var $table string |
10 | 10 | */ |
11 | - protected $table='users'; |
|
11 | + protected $table = 'users'; |
|
12 | 12 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * @var array |
9 | 9 | */ |
10 | - protected $query=[]; |
|
10 | + protected $query = []; |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * UserBuilderHelper constructor. |
@@ -16,10 +16,10 @@ discard block |
||
16 | 16 | { |
17 | 17 | //in addition to the default credentials values |
18 | 18 | // on the user side, a closure method is executed and an extra query occurs. |
19 | - $this->query['addToWhere']=$this->auth->getAddToWhere(); |
|
19 | + $this->query['addToWhere'] = $this->auth->getAddToWhere(); |
|
20 | 20 | |
21 | 21 | //we get the model specified for the builder. |
22 | - $this->query['driver']=$this->auth->getDriverNamespace(); |
|
22 | + $this->query['driver'] = $this->auth->getDriverNamespace(); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | protected function callbackQueryWithoutCredentials($driver) |
30 | 30 | { |
31 | - if($this->isCallableAddToWhere()){ |
|
31 | + if ($this->isCallableAddToWhere()) { |
|
32 | 32 | |
33 | 33 | return $driver::where(function($query) { |
34 | 34 | |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | protected function checkQuery($token) |
48 | 48 | { |
49 | 49 | //we get the model specified for the builder. |
50 | - $driver=$this->query['driver']; |
|
50 | + $driver = $this->query['driver']; |
|
51 | 51 | |
52 | 52 | //token query for builder |
53 | 53 | return $driver::where(function($query) use($token) { |
54 | 54 | |
55 | 55 | //where query for token |
56 | - $query->where('token',$token); |
|
56 | + $query->where('token', $token); |
|
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 |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | // if the addToWhereClosure value is a closure, |
106 | 106 | // then in this case we actually run |
107 | 107 | // the closure object and add it to the query value. |
108 | - if($this->isCallableAddToWhere()){ |
|
108 | + if ($this->isCallableAddToWhere()) { |
|
109 | 109 | $this->query['addToWhere']($query); |
110 | 110 | } |
111 | 111 | } |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | protected function setQuery($credentials) |
118 | 118 | { |
119 | 119 | //we get the model specified for the builder. |
120 | - $driver=$this->query['driver']; |
|
120 | + $driver = $this->query['driver']; |
|
121 | 121 | |
122 | - if(count($credentials->get())==0){ |
|
122 | + if (count($credentials->get())==0) { |
|
123 | 123 | |
124 | 124 | // if the credential array is empty in the config section, |
125 | 125 | // then you must run the query with a callable value of addToWhere value. |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | |
133 | 133 | // with the callback method (eloquent model) |
134 | 134 | // we write the where clause. |
135 | - foreach ($credentials->get() as $credential=>$credentialValue){ |
|
136 | - $query->where($credential,$credentialValue); |
|
135 | + foreach ($credentials->get() as $credential=>$credentialValue) { |
|
136 | + $query->where($credential, $credentialValue); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | // if the addToWhereClosure value is a closure, |
@@ -146,22 +146,22 @@ discard block |
||
146 | 146 | /** |
147 | 147 | * @return void|mixed |
148 | 148 | */ |
149 | - protected function updateToken($token=null) |
|
149 | + protected function updateToken($token = null) |
|
150 | 150 | { |
151 | 151 | //if query status value is true |
152 | - if($this->auth->params['status']){ |
|
152 | + if ($this->auth->params['status']) { |
|
153 | 153 | |
154 | 154 | // we go to the method that produces |
155 | 155 | // the classical token value and get the token value. |
156 | - $this->auth->params['token']=($token===null) ? $this->auth->getTokenData() : $token; |
|
156 | + $this->auth->params['token'] = ($token===null) ? $this->auth->getTokenData() : $token; |
|
157 | 157 | |
158 | 158 | // we update the token value. |
159 | 159 | // if there is no update, we reset the status value to 0. |
160 | - $update=$this->auth->params['builder']->update(['token'=>$this->auth->params['token']]); |
|
160 | + $update = $this->auth->params['builder']->update(['token'=>$this->auth->params['token']]); |
|
161 | 161 | |
162 | - if(!$update){ |
|
163 | - $this->auth->params['status']=0; |
|
164 | - $this->auth->params['exception']='update'; |
|
162 | + if (!$update) { |
|
163 | + $this->auth->params['status'] = 0; |
|
164 | + $this->auth->params['exception'] = 'update'; |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | protected function paramValues(...$params) |
12 | 12 | { |
13 | - list($type,$query)=$params; |
|
13 | + list($type, $query) = $params; |
|
14 | 14 | |
15 | 15 | // with query we bind the returned values to the params property of the auth object. |
16 | 16 | // and so the auth object will make a final return with these values. |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | // if status is true, |
22 | 22 | // we add values for some user benefits to params global access. |
23 | - if($this->auth->params['status']){ |
|
23 | + if ($this->auth->params['status']) { |
|
24 | 24 | |
25 | 25 | $this->auth->params['auth'] = $query->get(); |
26 | 26 | $this->auth->params['data'] = $query->first(); |
@@ -44,7 +44,7 @@ |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | //logout exception |
47 | - $this->logoutException(); |
|
47 | + $this->logoutException(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * @var array $params |
9 | 9 | */ |
10 | - public $params=[]; |
|
10 | + public $params = []; |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * @return bool |
@@ -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 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | //in the params property, we set the exception type according to the exception value. |
68 | - $exceptionType=(isset($this->params['exception'])) ? $this->params['exception'] : 'credentials'; |
|
68 | + $exceptionType = (isset($this->params['exception'])) ? $this->params['exception'] : 'credentials'; |
|
69 | 69 | |
70 | 70 | // if the status is unsuccessful, |
71 | 71 | // the direct exception will be thrown away. |