From 07a8992a84c252ab10d6047e3de1ce16ac3c6b0b Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 22 Apr 2010 20:08:38 +0200 Subject: [PATCH] admins can now create new users --- inc/lib_config.php | 12 ++++++++++++ inc/lib_user.php | 7 +++++-- inc/templates/configform.php | 12 +++++++++++- inc/templates/header.php | 3 +++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/inc/lib_config.php b/inc/lib_config.php index 0522ef3862f..5fa6b5f7c64 100755 --- a/inc/lib_config.php +++ b/inc/lib_config.php @@ -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 * diff --git a/inc/lib_user.php b/inc/lib_user.php index eb515b92a00..e7855b5b7b3 100644 --- a/inc/lib_user.php +++ b/inc/lib_user.php @@ -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 diff --git a/inc/templates/configform.php b/inc/templates/configform.php index 61217df2acf..ba946fc67b0 100755 --- a/inc/templates/configform.php +++ b/inc/templates/configform.php @@ -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(); ?> \ No newline at end of file diff --git a/inc/templates/header.php b/inc/templates/header.php index bd4ccaf35e3..46c64bfd645 100755 --- a/inc/templates/header.php +++ b/inc/templates/header.php @@ -33,6 +33,9 @@ echo('