Skip to content

Commit

Permalink
More username tests.
Browse files Browse the repository at this point in the history
Fix the username validation stuff now.
  • Loading branch information
mastacontrola committed Jan 9, 2017
1 parent 862e48f commit e361c76
Show file tree
Hide file tree
Showing 12 changed files with 380 additions and 148 deletions.
2 changes: 1 addition & 1 deletion packages/web/lib/fog/system.class.php
Expand Up @@ -53,7 +53,7 @@ private static function _versionCompare()
public function __construct()
{
self::_versionCompare();
define('FOG_VERSION', '8');
define('FOG_VERSION', '9');
define('FOG_SCHEMA', 245);
define('FOG_BCACHE_VER', 111);
define('FOG_SVN_REVISION', 6052);
Expand Down
4 changes: 2 additions & 2 deletions packages/web/lib/fog/user.class.php
Expand Up @@ -128,7 +128,7 @@ public function passwordValidate(
* immediately if found.
*/
$test = preg_match(
'/(?=^.{3,40}$)^[\w][\w0-9]*[._@-]?[\w0-9]*[.]?[\w0-9]+$/i',
'/(?=^.{3,40}$)^[\w][\w0-9]*[._-]?[\w0-9]*[.]?[\w0-9]+$/i',
$username
);
if (!$test) {
Expand Down Expand Up @@ -183,7 +183,7 @@ public function validatePw(
* immediately if found.
*/
$test = preg_match(
'/(?=^.{3,40}$)^[\w][\w0-9]*[._@-]?[\w0-9]*[.]?[\w0-9]+$/i',
'/(?=^.{3,40}$)^[\w][\w0-9]*[._-]?[\w0-9]*[.]?[\w0-9]+$/i',
$username
);
if (!$test) {
Expand Down
32 changes: 32 additions & 0 deletions packages/web/lib/pages/usermanagementpage.class.php
Expand Up @@ -192,6 +192,22 @@ public function addPost()
->processEvent('USER_ADD_POST');
try {
$name = strtolower(trim($_REQUEST['name']));
$test = preg_match(
'/(?=^.{3,40}$)^[\w][\w0-9]*[._-]?[\w0-9]*[.]?[\w0-9]+$/i',
$name
);
if (!$test) {
throw new Exception(
sprintf(
'%s.<br/><small>%s.<br/>%s.<br/>%s.</br>%s.</small>',
_('Username does not meet rules'),
_('Must start with a word character'),
_('Must be at least 3 characters'),
_('Must be shorter than 41 characters'),
_('No contiguous special characters')
)
);
}
if (self::getClass('UserManager')->exists($name)) {
throw new Exception(_('Username already exists'));
}
Expand Down Expand Up @@ -309,6 +325,22 @@ public function editPost()
);
try {
$name = strtolower(trim($_REQUEST['name']));
$test = preg_match(
'/(?=^.{3,40}$)^[\w][\w0-9]*[._-]?[\w0-9]*[.]?[\w0-9]+$/i',
$name
);
if (!$test) {
throw new Exception(
sprintf(
'%s.<br/><small>%s.<br/>%s.<br/>%s.</br>%s.</small>',
_('Username does not meet rules'),
_('Must start with a word character'),
_('Must be at least 3 characters'),
_('Must be shorter than 41 characters'),
_('No contiguous special characters')
)
);
}
if ($name != trim($this->obj->get('name'))
&& $this->obj->getManager()->exists($name, $this->obj->get('id'))
) {
Expand Down
2 changes: 1 addition & 1 deletion packages/web/lib/plugins/ldap/class/ldap.class.php
Expand Up @@ -245,7 +245,7 @@ public function authLDAP($user, $pass)
* immediately if found.
*/
$test = preg_match(
'/(?=^.{3,40}$)^[\w][\w0-9]*[._@-]?[\w0-9]*[.]?[\w0-9]+$/i',
'/(?=^.{3,40}$)^[\w][\w0-9]*[._-]?[\w0-9]*[.]?[\w0-9]+$/i',
$user
);
if (!$test) {
Expand Down
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: fog-project-2\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-09 14:44-0500\n"
"POT-Creation-Date: 2017-01-09 15:20-0500\n"
"PO-Revision-Date: 2016-05-23 07:36-0400\n"
"Last-Translator: vspushbullet <vspushbullet@gmail.com>\n"
"Language-Team: German\n"
Expand Down Expand Up @@ -1316,7 +1316,7 @@ msgstr "Bild bearbeiten"
#: /var/www/fog/lib/pages/groupmanagementpage.class.php:383
#: /var/www/fog/lib/pages/groupmanagementpage.class.php:654
#: /var/www/fog/lib/pages/usermanagementpage.class.php:68
#: /var/www/fog/lib/pages/usermanagementpage.class.php:231
#: /var/www/fog/lib/pages/usermanagementpage.class.php:247
#: /var/www/fog/lib/pages/hostmanagementpage.class.php:598
#: /var/www/fog/lib/pages/hostmanagementpage.class.php:1075
#: /var/www/fog/lib/pages/snapinmanagementpage.class.php:171
Expand Down Expand Up @@ -1544,7 +1544,7 @@ msgstr "Hinzufügen"
#: /var/www/fog/lib/pages/groupmanagementpage.class.php:853
#: /var/www/fog/lib/pages/groupmanagementpage.class.php:929
#: /var/www/fog/lib/pages/groupmanagementpage.class.php:978
#: /var/www/fog/lib/pages/usermanagementpage.class.php:268
#: /var/www/fog/lib/pages/usermanagementpage.class.php:284
#: /var/www/fog/lib/pages/schemaupdaterpage.class.php:166
#: /var/www/fog/lib/pages/schemaupdaterpage.class.php:183
#: /var/www/fog/lib/pages/hostmanagementpage.class.php:793
Expand Down Expand Up @@ -4337,42 +4337,42 @@ msgid "New User"
msgstr "Neuer Benutzer"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:138
#: /var/www/fog/lib/pages/usermanagementpage.class.php:236
#: /var/www/fog/lib/pages/usermanagementpage.class.php:252
msgid "User Name"
msgstr "Benutzername"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:143
#: /var/www/fog/lib/pages/usermanagementpage.class.php:241
#: /var/www/fog/lib/pages/usermanagementpage.class.php:257
msgid "User Password"
msgstr "Benutzer-Passwort"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:146
#: /var/www/fog/lib/pages/usermanagementpage.class.php:244
#: /var/www/fog/lib/pages/usermanagementpage.class.php:260
msgid "User Password (confirm)"
msgstr "Benutzer-Passwort (bestätigen)"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:152
#: /var/www/fog/lib/pages/usermanagementpage.class.php:250
#: /var/www/fog/lib/pages/usermanagementpage.class.php:266
msgid "Mobile/Quick Image Access Only?"
msgstr "Mobile/Quick Image Access nur?"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:155
#: /var/www/fog/lib/pages/usermanagementpage.class.php:253
#: /var/www/fog/lib/pages/usermanagementpage.class.php:269
msgid "Warning"
msgstr ""

#: /var/www/fog/lib/pages/usermanagementpage.class.php:156
#: /var/www/fog/lib/pages/usermanagementpage.class.php:254
#: /var/www/fog/lib/pages/usermanagementpage.class.php:270
msgid "if you tick this box"
msgstr ""

#: /var/www/fog/lib/pages/usermanagementpage.class.php:157
#: /var/www/fog/lib/pages/usermanagementpage.class.php:255
#: /var/www/fog/lib/pages/usermanagementpage.class.php:271
msgid "this user will not be able to log into"
msgstr ""

#: /var/www/fog/lib/pages/usermanagementpage.class.php:158
#: /var/www/fog/lib/pages/usermanagementpage.class.php:256
#: /var/www/fog/lib/pages/usermanagementpage.class.php:272
msgid "this FOG Management console in the future"
msgstr ""

Expand All @@ -4384,28 +4384,53 @@ msgstr "Benutzer erstellen"
msgid "Add new user account"
msgstr "Neuen Benutzer-Account hinzufügen"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:196
#: /var/www/fog/lib/pages/usermanagementpage.class.php:315
#: /var/www/fog/lib/pages/usermanagementpage.class.php:203
#: /var/www/fog/lib/pages/usermanagementpage.class.php:336
msgid "Username does not meet rules"
msgstr ""

#: /var/www/fog/lib/pages/usermanagementpage.class.php:204
#: /var/www/fog/lib/pages/usermanagementpage.class.php:337
msgid "Must start with a word character"
msgstr ""

#: /var/www/fog/lib/pages/usermanagementpage.class.php:205
#: /var/www/fog/lib/pages/usermanagementpage.class.php:338
msgid "Must be at least 3 characters"
msgstr ""

#: /var/www/fog/lib/pages/usermanagementpage.class.php:206
#: /var/www/fog/lib/pages/usermanagementpage.class.php:339
msgid "Must be shorter than 41 characters"
msgstr ""

#: /var/www/fog/lib/pages/usermanagementpage.class.php:207
#: /var/www/fog/lib/pages/usermanagementpage.class.php:340
msgid "No contiguous special characters"
msgstr ""

#: /var/www/fog/lib/pages/usermanagementpage.class.php:212
#: /var/www/fog/lib/pages/usermanagementpage.class.php:347
msgid "Username already exists"
msgstr "Benutzername ist bereits vorhanden."

#: /var/www/fog/lib/pages/usermanagementpage.class.php:203
#: /var/www/fog/lib/pages/usermanagementpage.class.php:219
msgid "Failed to create user"
msgstr "Fehler beim Benutzer erstellen"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:208
#: /var/www/fog/lib/pages/usermanagementpage.class.php:224
msgid "User created"
msgstr "Benutzer erstellt"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:209
#: /var/www/fog/lib/pages/usermanagementpage.class.php:225
msgid "You may now create another"
msgstr "Sie können jetzt eine andere erstellen"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:322
#: /var/www/fog/lib/pages/usermanagementpage.class.php:354
msgid "User update failed"
msgstr "Benutzer-Update fehlgeschlagen"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:325
#: /var/www/fog/lib/pages/usermanagementpage.class.php:357
msgid "User updated"
msgstr "Benutzer aktualisiert"

Expand Down
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-09 14:44-0500\n"
"POT-Creation-Date: 2017-01-09 15:20-0500\n"
"PO-Revision-Date: 2016-05-22 15:14-0400\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
Expand Down Expand Up @@ -1308,7 +1308,7 @@ msgstr "Edit Image"
#: /var/www/fog/lib/pages/groupmanagementpage.class.php:383
#: /var/www/fog/lib/pages/groupmanagementpage.class.php:654
#: /var/www/fog/lib/pages/usermanagementpage.class.php:68
#: /var/www/fog/lib/pages/usermanagementpage.class.php:231
#: /var/www/fog/lib/pages/usermanagementpage.class.php:247
#: /var/www/fog/lib/pages/hostmanagementpage.class.php:598
#: /var/www/fog/lib/pages/hostmanagementpage.class.php:1075
#: /var/www/fog/lib/pages/snapinmanagementpage.class.php:171
Expand Down Expand Up @@ -1536,7 +1536,7 @@ msgstr "Add"
#: /var/www/fog/lib/pages/groupmanagementpage.class.php:853
#: /var/www/fog/lib/pages/groupmanagementpage.class.php:929
#: /var/www/fog/lib/pages/groupmanagementpage.class.php:978
#: /var/www/fog/lib/pages/usermanagementpage.class.php:268
#: /var/www/fog/lib/pages/usermanagementpage.class.php:284
#: /var/www/fog/lib/pages/schemaupdaterpage.class.php:166
#: /var/www/fog/lib/pages/schemaupdaterpage.class.php:183
#: /var/www/fog/lib/pages/hostmanagementpage.class.php:793
Expand Down Expand Up @@ -4324,42 +4324,42 @@ msgid "New User"
msgstr "New User"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:138
#: /var/www/fog/lib/pages/usermanagementpage.class.php:236
#: /var/www/fog/lib/pages/usermanagementpage.class.php:252
msgid "User Name"
msgstr "User Name"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:143
#: /var/www/fog/lib/pages/usermanagementpage.class.php:241
#: /var/www/fog/lib/pages/usermanagementpage.class.php:257
msgid "User Password"
msgstr "User Password"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:146
#: /var/www/fog/lib/pages/usermanagementpage.class.php:244
#: /var/www/fog/lib/pages/usermanagementpage.class.php:260
msgid "User Password (confirm)"
msgstr "User Password (confirm)"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:152
#: /var/www/fog/lib/pages/usermanagementpage.class.php:250
#: /var/www/fog/lib/pages/usermanagementpage.class.php:266
msgid "Mobile/Quick Image Access Only?"
msgstr "Mobile/Quick Image Access Only?"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:155
#: /var/www/fog/lib/pages/usermanagementpage.class.php:253
#: /var/www/fog/lib/pages/usermanagementpage.class.php:269
msgid "Warning"
msgstr ""

#: /var/www/fog/lib/pages/usermanagementpage.class.php:156
#: /var/www/fog/lib/pages/usermanagementpage.class.php:254
#: /var/www/fog/lib/pages/usermanagementpage.class.php:270
msgid "if you tick this box"
msgstr ""

#: /var/www/fog/lib/pages/usermanagementpage.class.php:157
#: /var/www/fog/lib/pages/usermanagementpage.class.php:255
#: /var/www/fog/lib/pages/usermanagementpage.class.php:271
msgid "this user will not be able to log into"
msgstr ""

#: /var/www/fog/lib/pages/usermanagementpage.class.php:158
#: /var/www/fog/lib/pages/usermanagementpage.class.php:256
#: /var/www/fog/lib/pages/usermanagementpage.class.php:272
msgid "this FOG Management console in the future"
msgstr ""

Expand All @@ -4371,28 +4371,53 @@ msgstr "Create User"
msgid "Add new user account"
msgstr "Add new user account"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:196
#: /var/www/fog/lib/pages/usermanagementpage.class.php:315
#: /var/www/fog/lib/pages/usermanagementpage.class.php:203
#: /var/www/fog/lib/pages/usermanagementpage.class.php:336
msgid "Username does not meet rules"
msgstr ""

#: /var/www/fog/lib/pages/usermanagementpage.class.php:204
#: /var/www/fog/lib/pages/usermanagementpage.class.php:337
msgid "Must start with a word character"
msgstr ""

#: /var/www/fog/lib/pages/usermanagementpage.class.php:205
#: /var/www/fog/lib/pages/usermanagementpage.class.php:338
msgid "Must be at least 3 characters"
msgstr ""

#: /var/www/fog/lib/pages/usermanagementpage.class.php:206
#: /var/www/fog/lib/pages/usermanagementpage.class.php:339
msgid "Must be shorter than 41 characters"
msgstr ""

#: /var/www/fog/lib/pages/usermanagementpage.class.php:207
#: /var/www/fog/lib/pages/usermanagementpage.class.php:340
msgid "No contiguous special characters"
msgstr ""

#: /var/www/fog/lib/pages/usermanagementpage.class.php:212
#: /var/www/fog/lib/pages/usermanagementpage.class.php:347
msgid "Username already exists"
msgstr "Username already exists"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:203
#: /var/www/fog/lib/pages/usermanagementpage.class.php:219
msgid "Failed to create user"
msgstr "Failed to create user"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:208
#: /var/www/fog/lib/pages/usermanagementpage.class.php:224
msgid "User created"
msgstr "User created"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:209
#: /var/www/fog/lib/pages/usermanagementpage.class.php:225
msgid "You may now create another"
msgstr "You may now create another"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:322
#: /var/www/fog/lib/pages/usermanagementpage.class.php:354
msgid "User update failed"
msgstr "User update failed"

#: /var/www/fog/lib/pages/usermanagementpage.class.php:325
#: /var/www/fog/lib/pages/usermanagementpage.class.php:357
msgid "User updated"
msgstr "User updated"

Expand Down

0 comments on commit e361c76

Please sign in to comment.