added post_createUser hook
This commit is contained in:
parent
61ed347d26
commit
b2d021b2a5
|
@ -48,15 +48,9 @@ class Hooks {
|
|||
|
||||
$util = new Util( $view, $params['uid'] );
|
||||
|
||||
// Check files_encryption infrastructure is ready for action
|
||||
if ( ! $util->ready() ) {
|
||||
|
||||
\OC_Log::write( 'Encryption library', 'User account "' . $params['uid'] . '" is not ready for encryption; configuration started', \OC_Log::DEBUG );
|
||||
|
||||
if(!$util->setupServerSide( $params['password'] )) {
|
||||
// setup user, if user not ready force relogin
|
||||
if(Helper::setupUser($util, $params['password']) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
\OC_FileProxy::$enabled = false;
|
||||
|
@ -121,6 +115,18 @@ class Hooks {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief setup encryption backend upon user created
|
||||
* @note This method should never be called for users using client side encryption
|
||||
*/
|
||||
public static function postCreateUser( $params ) {
|
||||
$view = new \OC_FilesystemView( '/' );
|
||||
|
||||
$util = new Util( $view, $params['uid'] );
|
||||
|
||||
Helper::setupUser($util, $params['password']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Change a user's encryption passphrase
|
||||
* @param array $params keys: uid, password
|
||||
|
|
|
@ -48,6 +48,7 @@ class Helper {
|
|||
|
||||
\OCP\Util::connectHook( 'OC_User', 'post_login', 'OCA\Encryption\Hooks', 'login' );
|
||||
\OCP\Util::connectHook( 'OC_User', 'pre_setPassword', 'OCA\Encryption\Hooks', 'setPassphrase' );
|
||||
\OCP\Util::connectHook( 'OC_User', 'post_createUser', 'OCA\Encryption\Hooks', 'postCreateUser' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,5 +69,24 @@ class Helper {
|
|||
\OCP\Util::connectHook('OC_Filesystem', 'post_rename', 'OCA\Encryption\Hooks', 'postRename');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief setup user for files_encryption
|
||||
*
|
||||
* @param Util $util
|
||||
* @param string $password
|
||||
* @return bool
|
||||
*/
|
||||
public static function setupUser($util, $password) {
|
||||
// Check files_encryption infrastructure is ready for action
|
||||
if ( ! $util->ready() ) {
|
||||
|
||||
\OC_Log::write( 'Encryption library', 'User account "' . $util->getUserId() . '" is not ready for encryption; configuration started', \OC_Log::DEBUG );
|
||||
|
||||
if(!$util->setupServerSide( $password )) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue