add configuration value to restrict registration to an e?mail address (implements #4)
This commit is contained in:
parent
dcfb93ec6b
commit
c512dca087
5 changed files with 37 additions and 22 deletions
|
|
@ -143,10 +143,11 @@
|
|||
* @var array
|
||||
*/
|
||||
public static $misc = array(
|
||||
'ranking_range' => 2,
|
||||
'achievements_range' => 3,
|
||||
'title_delimiter' => ' – ',
|
||||
'lists_limit' => 10
|
||||
'registration_host' => '',
|
||||
'ranking_range' => 2,
|
||||
'achievements_range' => 3,
|
||||
'title_delimiter' => ' – ',
|
||||
'lists_limit' => 10
|
||||
);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -207,6 +207,7 @@
|
|||
|
||||
$fields = array('username', 'prename', 'surname', 'email', 'password');
|
||||
$validation = array();
|
||||
$emailhost = \nre\configs\AppConfig::$misc['registration_host'];
|
||||
|
||||
// Register a new user
|
||||
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('register')))
|
||||
|
|
@ -220,6 +221,11 @@
|
|||
$prename = $this->request->getPostParam('prename');
|
||||
$surname = $this->request->getPostParam('surname');
|
||||
$email = $this->request->getPostParam('email');
|
||||
if(!empty($emailhost)) {
|
||||
if(substr_compare($email, $emailhost, max(0, strlen($email)-strlen($emailhost)), strlen($emailhost)) !== 0) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'email', 'host', 'invalid');
|
||||
}
|
||||
}
|
||||
if($this->Users->emailExists($email)) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'email', 'exist', true);
|
||||
}
|
||||
|
|
@ -264,6 +270,7 @@
|
|||
$this->set('prename', $prename);
|
||||
$this->set('surname', $surname);
|
||||
$this->set('email', $email);
|
||||
$this->set('emailhost', $emailhost);
|
||||
$this->set('validation', $validation);
|
||||
$this->set('validationSettings', $validationSettings);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,15 +1,15 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: The Legend of Z\n"
|
||||
"POT-Creation-Date: 2015-03-21 14:54+0100\n"
|
||||
"PO-Revision-Date: 2015-03-21 14:55+0100\n"
|
||||
"POT-Creation-Date: 2015-04-08 12:28+0100\n"
|
||||
"PO-Revision-Date: 2015-04-08 12:29+0100\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: de_DE\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.7.4\n"
|
||||
"X-Generator: Poedit 1.7.5\n"
|
||||
"X-Poedit-Basepath: ../../../\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
|
|
@ -18,7 +18,7 @@ msgstr ""
|
|||
"X-Poedit-SearchPath-2: controllers\n"
|
||||
|
||||
#: controllers/CharactersController.inc:402
|
||||
#: controllers/UsersController.inc:322 views/ajax/characters/index.tpl:10
|
||||
#: controllers/UsersController.inc:329 views/ajax/characters/index.tpl:10
|
||||
#: views/ajax/users/index.tpl:10 views/html/characters/index.tpl:48
|
||||
#: views/html/characters/manage.tpl:35 views/html/characters/manage.tpl:50
|
||||
#: views/html/characters/manage.tpl:58 views/html/userroles/user.tpl:5
|
||||
|
|
@ -28,7 +28,7 @@ msgid "Admin"
|
|||
msgstr "Administrator"
|
||||
|
||||
#: controllers/CharactersController.inc:408
|
||||
#: controllers/UsersController.inc:328 views/ajax/characters/index.tpl:12
|
||||
#: controllers/UsersController.inc:335 views/ajax/characters/index.tpl:12
|
||||
#: views/ajax/users/index.tpl:12 views/html/characters/index.tpl:49
|
||||
#: views/html/characters/manage.tpl:36 views/html/characters/manage.tpl:51
|
||||
#: views/html/characters/manage.tpl:59 views/html/userroles/user.tpl:7
|
||||
|
|
@ -38,7 +38,7 @@ msgid "Moderator"
|
|||
msgstr "Moderator"
|
||||
|
||||
#: controllers/CharactersController.inc:414
|
||||
#: controllers/UsersController.inc:334 views/ajax/characters/index.tpl:14
|
||||
#: controllers/UsersController.inc:341 views/ajax/characters/index.tpl:14
|
||||
#: views/ajax/users/index.tpl:14 views/html/characters/index.tpl:50
|
||||
#: views/html/characters/manage.tpl:37 views/html/characters/manage.tpl:53
|
||||
#: views/html/characters/manage.tpl:61 views/html/userroles/user.tpl:9
|
||||
|
|
@ -1450,7 +1450,7 @@ msgstr "Login"
|
|||
#: views/html/users/index.tpl:15 views/html/users/index.tpl:19
|
||||
#: views/html/users/index.tpl:20 views/html/users/login.tpl:12
|
||||
#: views/html/users/login.tpl:13 views/html/users/manage.tpl:14
|
||||
#: views/html/users/register.tpl:83 views/html/users/register.tpl:84
|
||||
#: views/html/users/register.tpl:85 views/html/users/register.tpl:86
|
||||
msgid "Username"
|
||||
msgstr "Benutzername"
|
||||
|
||||
|
|
@ -1458,8 +1458,8 @@ msgstr "Benutzername"
|
|||
#: views/html/introduction/index.tpl:8 views/html/users/create.tpl:92
|
||||
#: views/html/users/create.tpl:93 views/html/users/edit.tpl:100
|
||||
#: views/html/users/edit.tpl:101 views/html/users/login.tpl:14
|
||||
#: views/html/users/login.tpl:15 views/html/users/register.tpl:91
|
||||
#: views/html/users/register.tpl:92
|
||||
#: views/html/users/login.tpl:15 views/html/users/register.tpl:93
|
||||
#: views/html/users/register.tpl:94
|
||||
msgid "Password"
|
||||
msgstr "Passwort"
|
||||
|
||||
|
|
@ -2031,7 +2031,7 @@ msgstr "Der Nachname ist ungültig"
|
|||
|
||||
#: views/html/users/create.tpl:54 views/html/users/create.tpl:58
|
||||
#: views/html/users/edit.tpl:58 views/html/users/edit.tpl:62
|
||||
#: views/html/users/register.tpl:54 views/html/users/register.tpl:58
|
||||
#: views/html/users/register.tpl:54 views/html/users/register.tpl:60
|
||||
msgid "E‑mail address invalid"
|
||||
msgstr "Die E‑Mail-Adresse ist ungültig"
|
||||
|
||||
|
|
@ -2041,37 +2041,37 @@ msgid "E‑mail address already exists"
|
|||
msgstr "E‑Mail-Adresse existiert bereits"
|
||||
|
||||
#: views/html/users/create.tpl:63 views/html/users/edit.tpl:67
|
||||
#: views/html/users/register.tpl:63
|
||||
#: views/html/users/register.tpl:65
|
||||
#, php-format
|
||||
msgid "Password is too short (min. %d chars)"
|
||||
msgstr "Das Passwort ist zu kurz (min. %d Zeichen)"
|
||||
|
||||
#: views/html/users/create.tpl:65 views/html/users/edit.tpl:69
|
||||
#: views/html/users/register.tpl:65
|
||||
#: views/html/users/register.tpl:67
|
||||
#, php-format
|
||||
msgid "Password is too long (max. %d chars)"
|
||||
msgstr "Das Passwort ist zu lang (max. %d Zeichen)"
|
||||
|
||||
#: views/html/users/create.tpl:67 views/html/users/edit.tpl:71
|
||||
#: views/html/users/register.tpl:67
|
||||
#: views/html/users/register.tpl:69
|
||||
msgid "Password invalid"
|
||||
msgstr "Das Passwort ist ungültig"
|
||||
|
||||
#: views/html/users/create.tpl:86 views/html/users/create.tpl:87
|
||||
#: views/html/users/edit.tpl:94 views/html/users/edit.tpl:95
|
||||
#: views/html/users/register.tpl:85 views/html/users/register.tpl:86
|
||||
#: views/html/users/register.tpl:87 views/html/users/register.tpl:88
|
||||
msgid "Prename"
|
||||
msgstr "Vorname"
|
||||
|
||||
#: views/html/users/create.tpl:88 views/html/users/create.tpl:89
|
||||
#: views/html/users/edit.tpl:96 views/html/users/edit.tpl:97
|
||||
#: views/html/users/register.tpl:87 views/html/users/register.tpl:88
|
||||
#: views/html/users/register.tpl:89 views/html/users/register.tpl:90
|
||||
msgid "Surname"
|
||||
msgstr "Nachname"
|
||||
|
||||
#: views/html/users/create.tpl:90 views/html/users/create.tpl:91
|
||||
#: views/html/users/edit.tpl:98 views/html/users/edit.tpl:99
|
||||
#: views/html/users/register.tpl:89 views/html/users/register.tpl:90
|
||||
#: views/html/users/register.tpl:91 views/html/users/register.tpl:92
|
||||
#: views/html/users/user.tpl:24
|
||||
msgid "E‑mail address"
|
||||
msgstr "E‑Mail-Adresse"
|
||||
|
|
@ -2109,7 +2109,12 @@ msgstr "Benutzer verwalten"
|
|||
msgid "Registration"
|
||||
msgstr "Registrierung"
|
||||
|
||||
#: views/html/users/register.tpl:94
|
||||
#: views/html/users/register.tpl:58
|
||||
#, php-format
|
||||
msgid "E‑Mail address has to end with @%s"
|
||||
msgstr "Die E‑Mail-Adresse muss auf @%s enden"
|
||||
|
||||
#: views/html/users/register.tpl:96
|
||||
msgid "Register"
|
||||
msgstr "Registrieren"
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@
|
|||
break;
|
||||
case 'exist': echo _('E‑mail address already exists');
|
||||
break;
|
||||
case 'host': printf(_('E‑Mail address has to end with @%s'), $emailhost);
|
||||
break;
|
||||
default: echo _('E‑mail address invalid');
|
||||
}
|
||||
break;
|
||||
|
|
@ -87,7 +89,7 @@
|
|||
<label for="surname"><?=_('Surname')?>:</label>
|
||||
<input name="surname" type="text" placeholder="<?=_('Surname')?>" title="<?=_('Surname')?>" required="required" maxlength="<?=$validationSettings['surname']['maxlength']?>" value="<?=$surname?>" <?=(array_key_exists('surname', $validation)) ? 'class="invalid"' : null?> /><br />
|
||||
<label for="email"><?=_('E‑mail address')?>:</label>
|
||||
<input name="email" type="email" placeholder="<?=_('E‑mail address')?>" title="<?=_('E‑mail address')?>" required="required" value="<?=$email?>" <?=(array_key_exists('email', $validation)) ? 'class="invalid"' : null?> /><br />
|
||||
<input name="email" type="email" placeholder="<?=(!empty($emailhost)) ? '…@'.$emailhost : _('E‑mail address')?>" title="<?=_('E‑mail address')?>" required="required" value="<?=$email?>" <?=(array_key_exists('email', $validation)) ? 'class="invalid"' : null?> /><br />
|
||||
<label for="password"><?=_('Password')?>:</label>
|
||||
<input name="password" type="password" placeholder="<?=_('Password')?>" title="<?=_('Password')?>" required="required" maxlength="<?=$validationSettings['password']['maxlength']?>" <?=(array_key_exists('password', $validation)) ? 'class="invalid"' : null?> /><br />
|
||||
</fieldset>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue