Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F5785
createAndPromote.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 10:40 PM
2014-11-21 22:40:17 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
createAndPromote.patch
View Options
Index: createAndPromote.php
===================================================================
--- createAndPromote.php (revision 50834)
+++ createAndPromote.php (working copy)
@@ -24,18 +24,28 @@
$username = $args[0];
$password = $args[1];
-echo( wfWikiID() . ": Creating and promoting User:{$username}..." );
+echo( wfWikiID() . ": Creating and promoting User:{$username}...\n" );
# Validate username and check it doesn't exist
$user = User::newFromName( $username );
if( !is_object( $user ) ) {
- echo( "invalid username.\n" );
+ echo( "$username is not a valid username.\n" );
die( 1 );
} elseif( 0 != $user->idForName() ) {
- echo( "account exists.\n" );
+ echo( "An account called $username already exists.\n" );
die( 1 );
}
+# Validate password
+if( strlen( $password ) < $wgMinimalPasswordLength) {
+ echo( "The password is too short. It must be at least $wgMinimalPasswordLength characters (\$wgMinimalPasswordLength).\n");
+ die( 1 );
+}
+if( $wgContLang->lc( $password ) === $wgContLang->lc( $username ) ) {
+ echo( "The password cannot be the same as the username.\n" );
+ die( 1 );
+}
+
# Insert the account into the database
$user->addToDatabase();
$user->setPassword( $password );
@@ -50,7 +60,7 @@
$ssu = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
$ssu->doUpdate();
-echo( "done.\n" );
+echo( "User:{$username} successfully created.\n" );
function showHelp() {
echo( <<<EOT
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5335
Default Alt Text
createAndPromote.patch (1 KB)
Attached To
Mode
T21157: createAndPromote error on bad password
Attached
Detach File
Event Timeline
Log In to Comment