]> git.mxchange.org Git - city.git/commitdiff
Added new files for login form + updated 'core'.
authorRoland Haeder <roland@mxchange.org>
Fri, 17 Apr 2015 18:52:39 +0000 (20:52 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 17 Apr 2015 18:52:39 +0000 (20:52 +0200)
Signed-off-by: Roland Haeder <roland@mxchange.org>
application/city/config.php
application/city/main/commands/html/class_HtmlCityGuestLoginCommand.php [new file with mode: 0644]
application/city/main/commands/html/class_HtmlCityUserLoginCommand.php [new file with mode: 0644]
application/city/main/controller/html/class_CityHtmlLoginController.php
application/city/templates/de/code/city_main.ctp
application/city/templates/de/code/login_form.ctp [new file with mode: 0644]
core

index c9af86e4f525f02928ade418aee702143d4b373e..66a93902a16763212751d55108b7176193dca972 100644 (file)
@@ -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 (file)
index 0000000..cc71d92
--- /dev/null
@@ -0,0 +1,112 @@
+<?php
+/**
+ * A command for guest logins
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 (file)
index 0000000..37c3d2d
--- /dev/null
@@ -0,0 +1,124 @@
+<?php
+/**
+ * A command for user login
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
index 5ac7d8af79c2f61199e33d0d754071092b59cf89..b0d0d6af1ba2f877ee90267a94c4036d320a2c48 100644 (file)
@@ -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
        }
 
        /**
index 006357e497e11e47151d80e976b4e32f910236f6..e053198035be58f23af208ee0d8935f89b03b13f 100644 (file)
@@ -18,6 +18,7 @@
 </div>
 
 <div id="main_content">
+       {?main_content?}
        {?content?}
 </div>
 
diff --git a/application/city/templates/de/code/login_form.ctp b/application/city/templates/de/code/login_form.ctp
new file mode 100644 (file)
index 0000000..272567c
--- /dev/null
@@ -0,0 +1,100 @@
+<?php
+// Get helper instance for web forms. This will add the opening form-tag to
+// the helper's render cache which is simply a small variable in the class
+// BaseHelper.
+$helperInstance = ObjectFactory::createObjectByConfiguredName('html_form_helper_class', array($this, 'city_user_login'));
+
+// Is the form enabled?
+if ($helperInstance->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&uuml;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&#39;s Spiel ist derzeit administrativ deaktiviert worden. Bitte komme sp&auml;ter noch mal wieder.");
+       $helperInstance->addFormNote('admin_notice', "Nachricht vom Admin: <span id=\"disabled_reason\">".$this->getConfigInstance()->readConfig('login_disabled_reason')."</span>");
+}
+
+// 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&uuml;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&auml;nkt. Mehr dazu unter &quot;Gastlogin&quot;.");
+       $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]
+?>
+<div id="content_header">
+       Einloggen zu <span class="app_name">{?app_full_name?}</span>
+</div>
+
+<div id="content_body">
+       <div id="login_box">
+               {?city_user_login?}
+       </div>
+
+       <div id="guest_login">
+               {?city_guest_login?}
+       </div>
+</div>
+
+<div id="content_footer">
+       Noch kein Spieleaccount? {?register?}
+</div>
diff --git a/core b/core
index 57d9c524afef252f209990a35283970907890c03..50591deeef32ed14e5f6c297c3633e378686ff2c 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 57d9c524afef252f209990a35283970907890c03
+Subproject commit 50591deeef32ed14e5f6c297c3633e378686ff2c