Skip to content

Commit 9cd7e30

Browse files
committed
Update ApiController.php
1 parent 7bdc10c commit 9cd7e30

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/ApiController.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ public function isHttpAuthenticated() : bool
3333
if ( $this->applyFilter('basic-authentication', true) ) {
3434
if ( $this->isBasicAuth() ) {
3535

36-
$username = $this->getBasicAuthUser();
37-
$password = $this->getBasicAuthPwd();
36+
$user = $this->getBasicAuthUser();
37+
$pswd = $this->getBasicAuthPwd();
3838

3939
// API authenticate override
4040
$this->doAction('api-authenticate', [
41-
'username' => $username,
41+
'username' => $user,
4242
'address' => $this->getServerIp(),
4343
'method' => 'basic'
4444
]);
4545

46-
if ( $username == $this->getApiUsername()
47-
&& $password == $this->getApiPassword() ) {
46+
if ( $user == $this->getApiUsername()
47+
&& $pswd == $this->getApiPassword() ) {
4848
return true;
4949
}
5050
}
@@ -74,22 +74,22 @@ public function isHttpAuthenticated() : bool
7474
*/
7575
protected function isGranted(string $token) : bool
7676
{
77-
$access = $this->getTokenAccess($token, $this->getSecret(true));
78-
$username = $this->matchString($this->getTokenPattern(), $access, 1);
79-
$password = $this->matchString($this->getTokenPattern(), $access, 2);
77+
$access = $this->getTokenAccess($token, $this->getSecret(true));
78+
$user = $access['user'] ?? false;
79+
$pswd = $access['pswd'] ?? false;
8080

81-
if ( $username && $password ) {
81+
if ( $user && $pswd ) {
8282

8383
// API authenticate override
8484
$this->doAction('api-authenticate', [
85-
'username' => $username,
85+
'username' => $user,
8686
'address' => $this->getServerIp(),
8787
'method' => 'token'
8888
]);
8989

9090
// Match authentication
91-
if ( $username == $this->getApiUsername()
92-
&& $password == $this->getApiPassword() ) {
91+
if ( $user == $this->getApiUsername()
92+
&& $pswd == $this->getApiPassword() ) {
9393
return true;
9494
}
9595
}

0 commit comments

Comments
 (0)