]> git.andy128k.dev Git - ipf.git/commitdiff
Create Superuser CLI Action
authoravl <alex.litovchenko@gmail.com>
Mon, 18 Aug 2008 13:22:16 +0000 (16:22 +0300)
committeravl <alex.litovchenko@gmail.com>
Mon, 18 Aug 2008 13:22:16 +0000 (16:22 +0300)
ipf/cli.php

index 7e881c09bbcf01a907928e476264f77b7b1d6756..74222a14bbec7de2137d163475c7783554772945 100644 (file)
@@ -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";