From daa5a6fc9d393ddde4e9a436a2030f3b9c48b6b5 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 18 Apr 2015 12:30:59 +0200 Subject: [PATCH] Cleanup of old stuff. Signed-off-by: Roland Haeder --- .../main/login/class_ShipSimuGuestLogin.php | 28 ++----------------- .../main/login/class_ShipSimuUserLogin.php | 11 ++------ .../shipsimu/templates/de/code/login_form.ctp | 15 +++++----- core | 2 +- 4 files changed, 13 insertions(+), 43 deletions(-) diff --git a/application/shipsimu/main/login/class_ShipSimuGuestLogin.php b/application/shipsimu/main/login/class_ShipSimuGuestLogin.php index 16f76ed..9725449 100644 --- a/application/shipsimu/main/login/class_ShipSimuGuestLogin.php +++ b/application/shipsimu/main/login/class_ShipSimuGuestLogin.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class ShipSimuGuestLogin extends BaseFrameworkSystem implements LoginableUser { +class ShipSimuGuestLogin extends BaseFrameworkSystem implements LoginableUser, Registerable { /** * The hashed password */ @@ -58,36 +58,12 @@ class ShipSimuGuestLogin extends BaseFrameworkSystem implements LoginableUser { * @param $requestInstance An instance of a Requestable class * @param $responseInstance An instance of a Responseable class * @return void - * @throws UserAuthMethodException If wether username nor email login - * was detected - * @throws MissingMethodException If a method was not found in the - * User class * @throws UserPasswordMismatchException If the supplied password did not * match with the stored password */ public function doLogin (Requestable $requestInstance, Responseable $responseInstance) { - // By default no method is selected - $method = null; - $data = ""; - - // Detect login method (username or email) and try to get a userinstance - if (!is_null($requestInstance->getRequestElement('user'))) { - // Username found! - $method = 'createGuestByUsername'; - $data = $requestInstance->getRequestElement('user'); - } // END - if - - // Is a method detected? - if (is_null($method)) { - // Then abort here - throw new UserAuthMethodException($this, self::EXCEPTION_MISSING_METHOD); - } elseif (!method_exists($this->getConfigInstance()->getConfigEntry('guest_class'), $method)) { - // The method is invalid! - throw new MissingMethodException(array($this, $method), self::EXCEPTION_MISSING_METHOD); - } - // Get a user instance - $userInstance = call_user_func_array(array($this->getConfigInstance()->getConfigEntry('guest_class'), $method), array($data)); + $userInstance = LoginFactory::createLoginObjectByRequest($requestInstance); // Remember this new instance in registry Registry::getRegistry()->addInstance('user', $userInstance); diff --git a/application/shipsimu/main/login/class_ShipSimuUserLogin.php b/application/shipsimu/main/login/class_ShipSimuUserLogin.php index cf43ef0..0b3cf7c 100644 --- a/application/shipsimu/main/login/class_ShipSimuUserLogin.php +++ b/application/shipsimu/main/login/class_ShipSimuUserLogin.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser { +class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser, Registerable { /** * The hashed password */ @@ -65,15 +65,8 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser { * @todo user account. */ public function doLogin (Requestable $requestInstance, Responseable $responseInstance) { - // By default no method is selected - $method = null; - $data = ""; - - // Get member class - $userClass = $this->getConfigInstance()->getConfigEntry('user_class'); - // Get a user instance - $userInstance = call_user_func_array(array($userClass, 'createMemberByRequest'), array($requestInstance)); + $userInstance = LoginFactory::createLoginObjectByRequest($requestInstance); // Remember this new instance in registry Registry::getRegistry()->addInstance('user', $userInstance); diff --git a/application/shipsimu/templates/de/code/login_form.ctp b/application/shipsimu/templates/de/code/login_form.ctp index 9de613a..b8a52e2 100644 --- a/application/shipsimu/templates/de/code/login_form.ctp +++ b/application/shipsimu/templates/de/code/login_form.ctp @@ -4,29 +4,30 @@ // BaseHelper. $helperInstance = ObjectFactory::createObjectByConfiguredName('html_form_helper_class', array($this, 'shipsimu_user_login')); -// Formular deaktiviert? +// Is the form enabled? if ($helperInstance->ifLoginIsEnabled()) { - // Formular ist aktiv + // Form is active $helperInstance->addFormGroup('login', "Gebe hier deine Logindaten ein:"); - // Welches Loginverfahren wurde konfiguriert? + // Which login method has been configured? if ($helperInstance->ifLoginWithUsername()) { - // Login mit Username + // Login with user name only $helperInstance->addFormSubGroup('username', "Bitte mit deinem Nickname einloggen."); $helperInstance->addFieldText('username', "Dein Nickname:"); $helperInstance->addInputTextField('username'); } elseif ($helperInstance->ifLoginWithEmail()) { - // Login mit Email + // Login with email address only $helperInstance->addFormSubGroup('email', "Bitte mit deiner Email-Adresse einloggen."); $helperInstance->addFieldText('email', "Deine Email-Addresse:"); $helperInstance->addInputTextField('email'); } else { - // Login mit Email/Username + // Login with email address or user name $helperInstance->addFormSubGroup('user_email', "Bitte mit deinem Nickname oder Email-Adresse einloggen."); $helperInstance->addFieldText('user_email', "Dein Nickname/Email:"); $helperInstance->addInputTextField('user_email'); } + // Add password input field $helperInstance->addFormSubGroup('pass', "Gebe dein Passwort von der Anmeldung ein."); $helperInstance->addFieldText('pass', "Dein Passwort:"); $helperInstance->addInputPasswordField('pass'); @@ -42,7 +43,7 @@ if ($helperInstance->ifLoginIsEnabled()) { $helperInstance->addInputResetButton("Formular leeren"); $helperInstance->addInputSubmitButton("Zum Spiel einloggen"); } else { - // Formular deaktiviert + // Form is inactive $helperInstance->addFormNote('form_deactivated', "Einloggen in's Spiel ist derzeit administrativ deaktiviert worden. Bitte komme später noch mal wieder."); $helperInstance->addFormNote('admin_notice', "Nachricht vom Admin: ".$this->getConfigInstance()->readConfig('login_disabled_reason').""); } diff --git a/core b/core index 57d9c52..7260d8e 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 57d9c524afef252f209990a35283970907890c03 +Subproject commit 7260d8e4851a8c34a98a72e77e2ec2d8d136cf7a -- 2.39.5