]> source.dussan.org Git - nextcloud-server.git/commitdiff
Emit hooks for user creation
authorTom Needham <needham.thomas@gmail.com>
Sat, 7 Apr 2012 22:00:32 +0000 (22:00 +0000)
committerTom Needham <needham.thomas@gmail.com>
Sat, 7 Apr 2012 22:00:32 +0000 (22:00 +0000)
lib/migrate.php

index 6734c805fcf56a52d94bb36d1f52e7ed80b5260b..2730d26a74a03c6a6160594e8c229bd1f899b30f 100644 (file)
@@ -232,10 +232,19 @@ class OC_Migrate{
                                        OC_Log::write( 'migration', 'User already exists', OC_Log::ERROR );
                                        return json_encode( array( 'success' => false ) );      
                                }
+                               $run = true;
+                               OC_Hook::emit( "OC_User", "pre_createUser", array( "run" => &$run, "uid" => self::$uid, "password" => $json->hash ));
+                               if( !$run ){
+                                       // Something stopped the user creation
+                                       OC_Log::write( 'migration', 'User creation failed', OC_Log::ERROR );
+                                       return json_encode( array( 'success' => false ) );      
+                               }
                                // Create the user
                                if( !self::createUser( self::$uid, $json->hash ) ){
                                        return json_encode( array( 'success' => false ) );      
                                }
+                               // Emit the post_createUser hook (password is already hashed, will cause problems
+                               OC_Hook::emit( "OC_User", "post_createUser", array( "uid" => self::$uid, "password" => $json->hash ));
                                // Make the new users data dir
                                $path = $datadir . '/' . self::$uid . '/files/';
                                if( !mkdir( $path, 0755, true ) ){