]> source.dussan.org Git - nextcloud-server.git/commitdiff
admins can now create new users
authorRobin <robin@Amaya.(none)>
Thu, 22 Apr 2010 18:08:38 +0000 (20:08 +0200)
committerRobin <robin@Amaya.(none)>
Thu, 22 Apr 2010 18:08:38 +0000 (20:08 +0200)
inc/lib_config.php
inc/lib_user.php
inc/templates/configform.php
inc/templates/header.php

index 0522ef3862f7e0c033c4f7ce36a397aa517938dc..5fa6b5f7c6481877a4f5d11ed099820943d58f5a 100755 (executable)
@@ -14,6 +14,18 @@ class OC_CONFIG{
     require('templates/configform.php');
   }
 
+       public static function createuserlisener(){
+               if(isset($_POST['new_username']) and isset($_POST['new_password'])){
+                       if(OC_USER::createuser($_POST['new_username'],$_POST['new_password'])){
+                               return 'user successfully created';
+                       }else{
+                               return 'error while trying to create user';
+                       }
+               }else{
+                       return false;
+               }
+       }
+
   /**
    * lisen for configuration changes and write it to the file
    *
index eb515b92a00129e1df889f183813f4a096d70747..e7855b5b7b37cdcb8f625d4d9310b6948fd34569 100644 (file)
@@ -32,8 +32,6 @@ class OC_USER {
        *
        */
        public static function loginlisener(){
-               global $CONFIG_ADMINLOGIN;
-               global $CONFIG_ADMINPASSWORD;
                if(isset($_POST['loginbutton']) and isset($_POST['password']) and isset($_POST['login'])){
                        if(OC_USER::login($_POST['login'],$_POST['password'])){
                                OC_LOG::event($_SESSION['username'],1,'');
@@ -45,6 +43,7 @@ class OC_USER {
                return('');
        }
        
+       
        /**
        * try to create a new user
        *
@@ -192,6 +191,10 @@ class OC_USER {
                        return true;
                }
        }
+       
+       public static function generatepassword(){
+               return uniqid();
+       }
 }
 
 ?>
\ No newline at end of file
index 61217df2acf37116ab51ae7b789fe3fc13f07e24..ba946fc67b0d71429dc0d406723ddac0f8d82609 100755 (executable)
@@ -4,6 +4,7 @@ global $CONFIG_ERROR;
 if(!isset($fillDB)) $fillDB=true;
 if(!isset($CONFIG_DBHOST)) $CONFIG_DBHOST='localhost';
 if(!isset($CONFIG_DBUSER)) $CONFIG_DBUSER='owncloud';
+$newuserpassword=OC_USER::generatepassword();
 ?>
 <script type="text/javascript">
 function showDBAdmin(){
@@ -82,7 +83,16 @@ if($CONFIG_DBTYPE=='sqlite'){
 <tr id='dbAdminPwd'><td>database administrative password:</td><td><input type="password" name="dbadminpwd" size="30" class="formstyle" value=''></input></td></tr>
 <tr><td>automaticly fill initial database:</td><td><input type="checkbox" name="filldb" size="30" class="formstyle" value='1' <?php if($FIRSTRUN) echo 'checked'; ?>></input></td></tr>
 <tr><td></td><td><input type="submit" name="set_config" alt="save" value="save" class="formstyle" /></td></tr>
-</table></form>
+</table></form><br/>
+<br/>
+<form method="post" enctype="multipart/form-data">
+<table cellpadding="5" cellspacing="5" border="0" class="loginform">
+<tr><td colspan='2'>Create new user:</td></tr>
+<tr><td>user name</td><td><input type='text' name='new_username' class="formstyle"></input></td></tr>
+<tr><td>password</td><td><input type='text' name='new_password' class="formstyle" autocomplete="off" value='<?php echo($newuserpassword);?>'></input></td></tr>
+<tr><td></td><td><input type='submit' value='create' class="formstyle"></input></td></tr>
+</table>
+</form>
 <script type="text/javascript">
     dbtypechange()
 </script>
\ No newline at end of file
index bd4ccaf35e3d1a4f7a6d454e65f1712a700d569f..46c64bfd6456a12dc92a1c371dc9338d05d67954 100755 (executable)
@@ -33,6 +33,9 @@ echo('<h1><a id="owncloud-logo" href="'.$WEBROOT.'"><span>ownCloud</span></a></h
 
   // check if already configured. otherwise start configuration wizard
   $error=OC_CONFIG::writeconfiglisener();
+  if($e=OC_CONFIG::createuserlisener()){
+       $error=$e;
+  }
   $CONFIG_ERROR=$error;
   global $CONFIG_INSTALLED;
   if(!$CONFIG_INSTALLED) {