commit 68e7722c48d3bd3d9830b08004ee6965a2241b4e
parent c343a7031b19f35dd1e98dc5fcb0ad7ddd57996b
Author: Jan Dankert <develop@jandankert.de>
Date: Tue, 29 Sep 2020 21:34:01 +0200
Refactoring: Do not use global constants.
Diffstat:
5 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/modules/cms/action/LoginAction.class.php b/modules/cms/action/LoginAction.class.php
@@ -707,11 +707,11 @@ class LoginAction extends BaseAction
$auth = new $moduleClass;
Logger::info('Trying to login with module '.$moduleClass);
$loginStatus = $auth->login( $loginName,$loginPassword, $token );
- $loginOk = $loginStatus === true || $loginStatus === OR_AUTH_STATUS_SUCCESS;
+ $loginOk = $loginStatus === true || $loginStatus === Auth::STATUS_SUCCESS;
- if ( $loginStatus === OR_AUTH_STATUS_PW_EXPIRED )
+ if ( $loginStatus === Auth::STATUS_PW_EXPIRED )
$mustChangePassword = true;
- if ( $loginStatus === OR_AUTH_STATUS_TOKEN_NEEDED )
+ if ( $loginStatus === Auth::STATUS_TOKEN_NEEDED )
$tokenFailed = true;
if ( $loginOk )
diff --git a/modules/cms/auth/Auth.class.php b/modules/cms/auth/Auth.class.php
@@ -5,21 +5,22 @@ namespace cms\auth;
use Benutzername;
use Kennwort;
-DEFINE('OR_AUTH_STATUS_SUCCESS', 1);
-DEFINE('OR_AUTH_STATUS_FAILED', 2);
-DEFINE('OR_AUTH_STATUS_PW_EXPIRED', 3);
-DEFINE('OR_AUTH_STATUS_TOKEN_NEEDED', 4);
-
interface Auth
{
+
+ const STATUS_SUCCESS = 1;
+ const STATUS_FAILED = 2;
+ const STATUS_PW_EXPIRED = 3;
+ const STATUS_TOKEN_NEEDED = 4;
+
const NS = __NAMESPACE__;
/**
* Prüft den eingegebenen Benutzernamen und das Kennwort
* auf Richtigkeit.
*
- * @param Benutzername
- * @param Kennwort
+ * @param string Benutzername
+ * @param string Kennwort
*/
function login($username, $password, $token);
diff --git a/modules/cms/auth/DatabaseAuth.class.php b/modules/cms/auth/DatabaseAuth.class.php
@@ -36,7 +36,7 @@ class DatabaseAuth implements Auth
// noch nicht implementiert: $authdb->close();
- return $ok ? OR_AUTH_STATUS_SUCCESS : OR_AUTH_STATUS_FAILED;
+ return $ok ? Auth::STATUS_SUCCESS : Auth::STATUS_FAILED;
}
public function username()
diff --git a/modules/cms/auth/IdentAuth.class.php b/modules/cms/auth/IdentAuth.class.php
@@ -50,7 +50,7 @@ class IdentAuth implements Auth
*/
public function login($user, $password, $token)
{
- return OR_AUTH_STATUS_FAILED;
+ return Auth::STATUS_FAILED;
}
}
diff --git a/modules/cms/auth/InternalAuth.class.php b/modules/cms/auth/InternalAuth.class.php
@@ -51,7 +51,7 @@ SQL
if (\cms\base\Configuration::config('security', 'password', 'force_change_if_cleartext'))
// Kennwort steht in der Datenbank im Klartext.
// Das Kennwort muss geaendert werden
- return OR_AUTH_STATUS_PW_EXPIRED;
+ return Auth::STATUS_PW_EXPIRED;
// Anderenfalls ist das Login zwar moeglich, aber das Kennwort wird automatisch neu gehasht, weil der beste Algo erzwungen wird.
// Das Klartextkennwort waere danach ueberschrieben.
@@ -65,7 +65,7 @@ SQL
if ($row_user['password_expires'] + (\cms\base\Configuration::config('security', 'deny_after_expiration_duration') * 60 * 60) < time())
return false; // Abgelaufenes Kennwort wird nicht mehr akzeptiert.
else
- return OR_AUTH_STATUS_PW_EXPIRED; // Kennwort ist abgelaufen, kann aber noch geändert werden.
+ return Auth::STATUS_PW_EXPIRED; // Kennwort ist abgelaufen, kann aber noch geändert werden.
}
if ($row_user['totp'] == 1) {
@@ -74,7 +74,7 @@ SQL
if (Password::getTOTPCode($user->otpSecret) == $token)
return true;
else
- return OR_AUTH_STATUS_TOKEN_NEEDED;
+ return Auth::STATUS_TOKEN_NEEDED;
}
if ($row_user['hotp'] == 1) {