mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-02-04 13:06:53 +00:00
Make password an attribute
Signed-off-by: Pablo Zmdl <pablo@nextcloud.com>
This commit is contained in:
parent
4318488937
commit
c4c04ebcf4
3 changed files with 9 additions and 14 deletions
|
|
@ -15,7 +15,7 @@ readonly class AuthManager {
|
|||
}
|
||||
|
||||
public function CheckCredentials(string $password) : bool {
|
||||
return hash_equals($this->configurationManager->GetPassword(), $password);
|
||||
return hash_equals($this->configurationManager->password, $password);
|
||||
}
|
||||
|
||||
public function CheckToken(string $token) : bool {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ class ConfigurationManager
|
|||
set { $this->set('AIO_TOKEN', $value); }
|
||||
}
|
||||
|
||||
public string $password {
|
||||
get => $this->get('password', '');
|
||||
set { $this->set('password', $value); }
|
||||
}
|
||||
|
||||
public function GetConfig() : array
|
||||
{
|
||||
if ($this->config === [] && file_exists(DataConst::GetConfigFile()))
|
||||
|
|
@ -29,16 +34,6 @@ class ConfigurationManager
|
|||
return $this->config;
|
||||
}
|
||||
|
||||
public function GetPassword() : string {
|
||||
return $this->GetConfig()['password'];
|
||||
}
|
||||
|
||||
public function SetPassword(string $password) : void {
|
||||
$config = $this->GetConfig();
|
||||
$config['password'] = $password;
|
||||
$this->WriteConfig($config);
|
||||
}
|
||||
|
||||
private function get(string $key, mixed $fallbackValue = null) : mixed {
|
||||
return $this->GetConfig()[$key] ?? $fallbackValue;
|
||||
}
|
||||
|
|
@ -586,7 +581,7 @@ class ConfigurationManager
|
|||
throw new InvalidSettingConfigurationException("Please enter your current password.");
|
||||
}
|
||||
|
||||
if ($currentPassword !== $this->GetPassword()) {
|
||||
if ($currentPassword !== $this->password) {
|
||||
throw new InvalidSettingConfigurationException("The entered current password is not correct.");
|
||||
}
|
||||
|
||||
|
|
@ -603,7 +598,7 @@ class ConfigurationManager
|
|||
}
|
||||
|
||||
// All checks pass so set the password
|
||||
$this->SetPassword($newPassword);
|
||||
$this->set('password', $newPassword);
|
||||
}
|
||||
|
||||
public function GetApachePort() : string {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ readonly class Setup {
|
|||
}
|
||||
|
||||
$password = $this->passwordGenerator->GeneratePassword(8);
|
||||
$this->configurationManager->SetPassword($password);
|
||||
$this->configurationManager->password = $password;
|
||||
return $password;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue