diff options
author | Robin Appelman <icewind1991@gmail.com> | 2012-01-08 14:25:38 +0100 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2012-01-08 14:25:38 +0100 |
commit | 49337e0ad1db8ecf8244f057f729241d923ac2ff (patch) | |
tree | f524bd8e41f1b1549bb720dfd53bf101c7be605b /lib/setup.php | |
parent | ae711168c3308e013c0d24cc7f832ff91077e911 (diff) | |
download | nextcloud-server-49337e0ad1db8ecf8244f057f729241d923ac2ff.tar.gz nextcloud-server-49337e0ad1db8ecf8244f057f729241d923ac2ff.zip |
dont create a new user when it already exists
Diffstat (limited to 'lib/setup.php')
-rw-r--r-- | lib/setup.php | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/setup.php b/lib/setup.php index a65dc9453c2..ebe7a45a1f6 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -98,26 +98,33 @@ class OC_Setup { ); } else { + $oldUser=OC_Config::getValue('dbuser', false); + $oldPassword=OC_Config::getValue('dbpassword', false); + $query="SELECT user FROM mysql.user WHERE user='$dbuser'"; //this should be enough to check for admin rights in mysql if(mysql_query($query, $connection)) { //use the admin login data for the new database user //add prefix to the mysql user name to prevent collissions $dbusername=substr('oc_'.$username,0,16); - //hash the password so we don't need to store the admin config in the config file - $dbpassword=md5(time().$password); - - self::createDBUser($dbusername, $dbpassword, $connection); - - OC_Config::setValue('dbuser', $dbusername); - OC_Config::setValue('dbpassword', $dbpassword); + if($dbusername!=$oldUser){ + //hash the password so we don't need to store the admin config in the config file + $dbpassword=md5(time().$password); + + self::createDBUser($dbusername, $dbpassword, $connection); + + OC_Config::setValue('dbuser', $dbusername); + OC_Config::setValue('dbpassword', $dbpassword); + } //create the database self::createDatabase($dbname, $dbusername, $connection); } else { - OC_Config::setValue('dbuser', $dbuser); - OC_Config::setValue('dbpassword', $dbpass); + if($dbuser!=$oldUser){ + OC_Config::setValue('dbuser', $dbuser); + OC_Config::setValue('dbpassword', $dbpass); + } //create the database self::createDatabase($dbname, $dbuser, $connection); |