AuthConfig.php (mrbs-1.9.4) | : | AuthConfig.php (mrbs-1.10.0) | ||
---|---|---|---|---|
<?php | <?php | |||
namespace MRBS\Auth; | namespace MRBS\Auth; | |||
class AuthConfig extends Auth | class AuthConfig extends Auth | |||
{ | { | |||
/* authValidateUser($user, $pass) | /* validateUser($user, $pass) | |||
* | * | |||
* Checks if the specified username/password pair are valid | * Checks if the specified username/password pair are valid | |||
* | * | |||
* $user - The user name | * $user - The user name | |||
* $pass - The password | * $pass - The password | |||
* | * | |||
* Returns: | * Returns: | |||
* false - The pair are invalid or do not exist | * false - The pair are invalid or do not exist | |||
* string - The validated username | * string - The validated username | |||
*/ | */ | |||
public function validateUser($user, $pass) | public function validateUser(?string $user, ?string $pass) | |||
{ | { | |||
global $auth; | global $auth; | |||
// Check if we do not have a username/password | // Check if we do not have a username/password | |||
if(!isset($user) || !isset($pass) || strlen($pass)==0) | if(!isset($user) || !isset($pass) || strlen($pass)==0) | |||
{ | { | |||
return false; | return false; | |||
} | } | |||
if ((isset($auth["user"][$user]) && | if ((isset($auth["user"][$user]) && | |||
skipping to change at line 41 | skipping to change at line 41 | |||
($auth["user"][\MRBS\utf8_strtolower($user)] == $pass) | ($auth["user"][\MRBS\utf8_strtolower($user)] == $pass) | |||
)) | )) | |||
{ | { | |||
return $user; // User validated | return $user; // User validated | |||
} | } | |||
return false; // User unknown or password invalid | return false; // User unknown or password invalid | |||
} | } | |||
// Return an array of users, indexed by 'username' and 'display_name' | // Return an array of users, indexed by 'username' and 'display_name' | |||
public function getUsernames() | public function getUsernames() : array | |||
{ | { | |||
global $auth; | global $auth; | |||
$result = array(); | $result = array(); | |||
foreach ($auth['user'] as $user => $password) | foreach ($auth['user'] as $user => $password) | |||
{ | { | |||
$result[] = array('username' => $user, | $result[] = array('username' => $user, | |||
'display_name' => $user); | 'display_name' => $user); | |||
} | } | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 3 lines changed or added |