* 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 ShipSimuGuestLogin extends BaseFrameworkSystem implements LoginableUser {
+class ShipSimuGuestLogin extends BaseFrameworkSystem implements LoginableUser, Registerable {
/**
* The hashed password
*/
* @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);
* 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 ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser {
+class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser, Registerable {
/**
* The hashed password
*/
* @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);
// 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');
$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: <span id=\"disabled_reason\">".$this->getConfigInstance()->readConfig('login_disabled_reason')."</span>");
}
-Subproject commit 57d9c524afef252f209990a35283970907890c03
+Subproject commit 7260d8e4851a8c34a98a72e77e2ec2d8d136cf7a