summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Sack <kde@jakobsack.de>2011-04-18 11:48:52 +0200
committerJakob Sack <kde@jakobsack.de>2011-04-18 11:48:52 +0200
commitf22c05deab263129c7d278d5e4d097cd9ec5573a (patch)
tree91c3de77e41cc22ca3359151433530a0998cff45
parentb37fb9142f095b893db818437f8b42b58377f444 (diff)
downloadnextcloud-server-f22c05deab263129c7d278d5e4d097cd9ec5573a.tar.gz
nextcloud-server-f22c05deab263129c7d278d5e4d097cd9ec5573a.zip
Check for existance of group- and usernames, don't mix OC_USER and OC_GROUP!
-rw-r--r--lib/User/database.php4
-rw-r--r--lib/group.php5
-rw-r--r--lib/user.php11
3 files changed, 16 insertions, 4 deletions
diff --git a/lib/User/database.php b/lib/User/database.php
index a0d06d63074..1a4ddf44c4e 100644
--- a/lib/User/database.php
+++ b/lib/User/database.php
@@ -74,10 +74,6 @@ class OC_USER_DATABASE extends OC_USER_BACKEND {
* Deletes a user
*/
public static function deleteUser( $uid ){
- // Delete user
- $query = OC_DB::prepare( "DELETE FROM `*PREFIX*users` WHERE uid = ?" );
- $result = $query->execute( array( $uid ));
-
// Delete user-group-relation
$query = OC_DB::prepare( "DELETE FROM `*PREFIX*group_user` WHERE uid = ?" );
$result = $query->execute( array( $uid ));
diff --git a/lib/group.php b/lib/group.php
index ef8b7cecfb2..eb4aa3bbf28 100644
--- a/lib/group.php
+++ b/lib/group.php
@@ -104,6 +104,11 @@ class OC_GROUP {
if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $gid )){
return false;
}
+ // No empty group names!
+ if( !$gid ){
+ return false;
+ }
+
$run = true;
OC_HOOK::emit( "OC_GROUP", "pre_createGroup", array( "run" => &$run, "gid" => $gid ));
diff --git a/lib/user.php b/lib/user.php
index 82b012f3a5c..51e4ab358e1 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -114,6 +114,11 @@ class OC_USER {
if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $uid )){
return false;
}
+ // No empty username
+ if( !$uid ){
+ return false;
+ }
+
$run = true;
OC_HOOK::emit( "OC_USER", "pre_createUser", array( "run" => &$run, "uid" => $uid, "password" => $password ));
@@ -138,6 +143,12 @@ class OC_USER {
OC_HOOK::emit( "OC_USER", "pre_deleteUser", array( "run" => &$run, "uid" => $uid ));
if( $run && self::$_backend->deleteUser( $uid )){
+ // We have to delete the user from all groups
+ foreach( OC_GROUP::getUserGroups( $uid ) as $i ){
+ OC_GROUP::removeFromGroup( $uid, $i );
+ }
+
+ // Emit and exit
OC_HOOK::emit( "OC_USER", "post_deleteUser", array( "uid" => $uid ));
return true;
}