From: Roland Haeder Date: Fri, 17 Apr 2015 18:52:39 +0000 (+0200) Subject: Added new files for login form + updated 'core'. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a48424ce019a374ad7b5e3310a2558aec0352346;p=city.git Added new files for login form + updated 'core'. Signed-off-by: Roland Haeder --- diff --git a/application/city/config.php b/application/city/config.php index c9af86e..66a9390 100644 --- a/application/city/config.php +++ b/application/city/config.php @@ -183,25 +183,25 @@ $cfg->setConfigEntry('chat_enabled_aol', 'Y'); $cfg->setConfigEntry('chat_enabled_msn', 'Y'); // CFG: CITY-REGISTER-CAPTCHA-SECURED -$cfg->setConfigEntry('city_register_captcha_secured', 'Y'); +$cfg->setConfigEntry('city_register_captcha_secured', 'N'); // CFG: CITY-USER-LOGIN-CAPTCHA-SECURED -$cfg->setConfigEntry('city_user_login_captcha_secured', 'Y'); +$cfg->setConfigEntry('city_user_login_captcha_secured', 'N'); // CFG: CITY-GUEST-LOGIN-CAPTCHA-SECURED -$cfg->setConfigEntry('city_guest_login_captcha_secured', 'Y'); +$cfg->setConfigEntry('city_guest_login_captcha_secured', 'N'); // CFG: CITY-PROFILE-CAPTCHA-SECURED -$cfg->setConfigEntry('city_profile_captcha_secured', 'Y'); +$cfg->setConfigEntry('city_profile_captcha_secured', 'N'); // CFG: CITY-REFILL-CAPTCHA-SECURED -$cfg->setConfigEntry('city_refill_captcha_secured', 'Y'); +$cfg->setConfigEntry('city_refill_captcha_secured', 'N'); // CFG: CITY-GOVERNMENT-STARTUP-CAPTCHA-SECURED -$cfg->setConfigEntry('city_government_startup_captcha_secured', 'Y'); +$cfg->setConfigEntry('city_government_startup_captcha_secured', 'N'); // CFG: CITY-GOVERNMENT-TRAINING-CAPTCHA-SECURED -$cfg->setConfigEntry('city_government_training_captcha_secured', 'Y'); +$cfg->setConfigEntry('city_government_training_captcha_secured', 'N'); // CFG: CITY-REGISTER-CAPTCHA-CLASS $cfg->setConfigEntry('city_register_captcha_class', 'GraphicalCodeCaptcha'); @@ -437,6 +437,12 @@ $cfg->setConfigEntry('user_government_wrapper_class', 'UserGovernmentDatabaseWra // CFG: PAYMENT-DB-WRAPPER-CLASS $cfg->setConfigEntry('payment_db_wrapper_class', 'PaymentsDatabaseWrapper'); +// CFG: LOGIN-ENABLED +$cfg->setConfigEntry('login_enabled', 'Y'); + +// CFG: LOGIN-TYPE (username, email, both) +$cfg->setConfigEntry('login_type', 'username'); + /****************************************************************************** * Console client * ******************************************************************************/ diff --git a/application/city/main/commands/html/class_HtmlCityGuestLoginCommand.php b/application/city/main/commands/html/class_HtmlCityGuestLoginCommand.php new file mode 100644 index 0000000..cc71d92 --- /dev/null +++ b/application/city/main/commands/html/class_HtmlCityGuestLoginCommand.php @@ -0,0 +1,112 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 City Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlCityGuestLoginCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this command and sets the resolver instance + * + * @param $resolverInstance An instance of a command resolver + * @return $commandInstance The created command instance + */ + public static final function createHtmlCityGuestLoginCommand (CommandResolver $resolverInstance) { + // Get a new instance + $commandInstance = new HtmlCityGuestLoginCommand(); + + // Set the resolver instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // First get a GuestLogin instance + $loginInstance = ObjectFactory::createObjectByConfiguredName('guest_login_class'); + + // First set request and response instance + $loginInstance->setRequestInstance($requestInstance); + + // Encrypt the password + $loginInstance->encryptPassword('passwd'); + + // Do the login here + $loginInstance->doLogin($requestInstance, $responseInstance); + + // Was the login fine? Then redirect here + if ($loginInstance->ifLoginWasSuccessfull()) { + // Try to redirect here + try { + // Redirect... + $responseInstance->redirectToConfiguredUrl('app_login'); + + // Exit here + exit(); + } catch (FrameworkException $e) { + // Something went wrong here! + $responseInstance->addFatalMessage($e->getMessage()); + } + } else { + // Attach error message to the response + $responseInstance->addFatalMessage('failed_user_login'); + } + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + * @todo Add more filters + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Add username verifier filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_guest_verifier_filter')); + + // Add password verifier filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('passwd_guest_verifier_filter')); + + // Add CAPTCHA verifier code + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_guest_verifier_filter')); + } +} + +// [EOF] +?> diff --git a/application/city/main/commands/html/class_HtmlCityUserLoginCommand.php b/application/city/main/commands/html/class_HtmlCityUserLoginCommand.php new file mode 100644 index 0000000..37c3d2d --- /dev/null +++ b/application/city/main/commands/html/class_HtmlCityUserLoginCommand.php @@ -0,0 +1,124 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 City Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlCityUserLoginCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this command and sets the resolver instance + * + * @param $resolverInstance An instance of a command resolver + * @return $commandInstance The created command instance + */ + public static final function createHtmlCityUserLoginCommand (CommandResolver $resolverInstance) { + // Get a new instance + $commandInstance = new HtmlCityUserLoginCommand(); + + // Set the resolver instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // First get a UserLogin instance + $loginInstance = ObjectFactory::createObjectByConfiguredName('user_login_class'); + + // First set request and response instance + $loginInstance->setRequestInstance($requestInstance); + + // Encrypt the password + $loginInstance->encryptPassword('pass'); + + // Do the login here + $loginInstance->doLogin($requestInstance, $responseInstance); + + // Was the login fine? Then redirect here + if ($loginInstance->ifLoginWasSuccessfull()) { + // Try to redirect here + try { + // Redirect... + $responseInstance->redirectToConfiguredUrl('app_login'); + + // Exit here + exit(); + } catch (FrameworkException $e) { + // Something went wrong here! + $responseInstance->addFatalMessage($e->getMessage()); + } + } else { + // Attach error message to the response + $responseInstance->addFatalMessage('failed_user_login'); + } + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + * @todo Add more filters + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Which login type do we have? + switch ($this->getConfigInstance()->getConfigEntry('login_type')) { + case 'username': // Login via username + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_filter')); + break; + + case 'email': // Login via email + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_verifier_filter')); + break; + + default: // Wether username or email is set + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_email_verifier_filter')); + break; + } + + // Password verifier filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_verifier_filter')); + + // Add filter for CAPTCHA + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_user_verifier_filter')); + } +} + +// [EOF] +?> diff --git a/application/city/main/controller/html/class_CityHtmlLoginController.php b/application/city/main/controller/html/class_CityHtmlLoginController.php index 5ac7d8a..b0d0d6a 100644 --- a/application/city/main/controller/html/class_CityHtmlLoginController.php +++ b/application/city/main/controller/html/class_CityHtmlLoginController.php @@ -31,6 +31,11 @@ class CityHtmlLoginController extends BaseController implements Controller { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); + + // Init additional filter chains + foreach (array('shutdown') as $filterChain) { + $this->initFilterChain($filterChain); + } // END - foreach } /** diff --git a/application/city/templates/de/code/city_main.ctp b/application/city/templates/de/code/city_main.ctp index 006357e..e053198 100644 --- a/application/city/templates/de/code/city_main.ctp +++ b/application/city/templates/de/code/city_main.ctp @@ -18,6 +18,7 @@
+ {?main_content?} {?content?}
diff --git a/application/city/templates/de/code/login_form.ctp b/application/city/templates/de/code/login_form.ctp new file mode 100644 index 0000000..272567c --- /dev/null +++ b/application/city/templates/de/code/login_form.ctp @@ -0,0 +1,100 @@ +ifLoginIsEnabled()) { + // Form is active + $helperInstance->addFormGroup('login', "Gebe hier deine Logindaten ein:"); + + // Which login method has been configured? + if ($helperInstance->ifLoginWithUsername()) { + // 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 with email address only + $helperInstance->addFormSubGroup('email', "Bitte mit deiner Email-Adresse einloggen."); + $helperInstance->addFieldText('email', "Deine Email-Addresse:"); + $helperInstance->addInputTextField('email'); + } else { + // 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'); + + // CAPTCHA enabled? + if ($helperInstance->ifFormSecuredWithCaptcha()) { + $helperInstance->addFormGroup('captcha_user', "Das Benutzer-Login ist durch ein CAPTCHA geschützt. Bitte wiederhole den angezeigten Code, damit du dich einloggen kannst."); + $helperInstance->addCaptcha(); + } // END - if + + // Submit buttons + $helperInstance->addFormGroup('buttons_user', "Alles richtig eingegeben?"); + $helperInstance->addInputResetButton("Formular leeren"); + $helperInstance->addInputSubmitButton("Zum Spiel einloggen"); +} else { + // 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').""); +} + +// Formular schliessen +$helperInstance->flushContent(); + +// Ist Gastlogin erlaubt? +if ($helperInstance->ifGuestLoginAllowed()) { + // Neue Helper-Instanz holen + $helperInstance = ObjectFactory::createObjectByConfiguredName('html_form_helper_class', array($this, 'city_guest_login')); + $helperInstance->addInputHiddenConfiguredField('user', 'guest_login'); + $helperInstance->addInputHiddenConfiguredField('passwd', 'guest_login'); + + // CAPTCHA enbaled? + if ($helperInstance->ifFormSecuredWithCaptcha()) { + $helperInstance->addFormGroup('captcha_guest', "Unser Gast-Login ist durch ein CAPTCHA geschützt. Bitte wiederhole den angezeigten Code, damit du dich einloggen kannst."); + $helperInstance->addCaptcha(); + } // END - if + + // Submit button + $helperInstance->addFormGroup('buttons_guest', "Gastlogins sind in der Funkionsweise eingeschränkt. Mehr dazu unter "Gastlogin"."); + $helperInstance->addInputSubmitButton("Als Gast einloggen"); + $helperInstance->flushContent(); +} + +// Get helper instance +$helperInstance = ObjectFactory::createObjectByConfiguredName('html_link_helper_class', array($this, 'register')); + +// Set link text +$helperInstance->addLinkWithTextById('register_login'); + +// Flush the content +$helperInstance->flushContent(); + +// [EOC] +?> +
+ Einloggen zu {?app_full_name?} +
+ +
+
+ {?city_user_login?} +
+ +
+ {?city_guest_login?} +
+
+ + diff --git a/core b/core index 57d9c52..50591de 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 57d9c524afef252f209990a35283970907890c03 +Subproject commit 50591deeef32ed14e5f6c297c3633e378686ff2c