From dfdc4aa0b23468ad3a3917653cae1bcac5427a3d Mon Sep 17 00:00:00 2001 From: avl Date: Mon, 18 Aug 2008 16:22:16 +0300 Subject: [PATCH] Create Superuser CLI Action --- ipf/cli.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ipf/cli.php b/ipf/cli.php index 7e881c0..74222a1 100644 --- a/ipf/cli.php +++ b/ipf/cli.php @@ -5,7 +5,7 @@ class IPF_Cli{ protected $commands; public function __construct(){ - $this->commands = array('help','sql','buildmodels','syncdb'); + $this->commands = array('help','sql','buildmodels','syncdb', 'createsuperuser'); } protected function usage(&$args){ @@ -39,6 +39,24 @@ class IPF_Cli{ IPF_Project::getInstance()->generateModels(); } + protected function createSuperUser(&$args){ + print "Create SuperUser\n"; + + $username = ''; while ($username==''){ print " Username: "; $username = trim(fgets(STDIN)); }; + $password = ''; while ($password==''){ print " Password: "; $password = trim(fgets(STDIN)); }; + $email = ''; while ($email==''){ print " e-mail: "; $email = trim(fgets(STDIN)); }; + + $su = new User(); + $su->username = $username; + $su->email = $email; + $su->is_staff = true; + $su->is_active = true; + $su->is_superuser = true; + $su->setPassword($password); + $su->save(); + print "Done\n"; + } + public function run(){ print "IPF command line tool. Version: ".IPF_Version::$name."\n"; -- 2.49.0