diff options
Diffstat (limited to 'lib/private/Server.php')
-rw-r--r-- | lib/private/Server.php | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/lib/private/Server.php b/lib/private/Server.php index 5c32b3e98e2..4e62e2d2916 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -3,6 +3,7 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * @copyright Copyright (c) 2016, Lukas Reschke <lukas@statuscode.ch> * + * @author Arne Hamann <kontakt+github@arne.email> * @author Arthur Schiwon <blizzz@arthur-schiwon.de> * @author Bart Visscher <bartv@thisnet.nl> * @author Bernhard Posselt <dev@bernhard-posselt.com> @@ -62,6 +63,8 @@ use OC\App\AppStore\Fetcher\CategoryFetcher; use OC\AppFramework\Http\Request; use OC\AppFramework\Utility\SimpleContainer; use OC\AppFramework\Utility\TimeFactory; +use OC\Authentication\Events\LoginFailed; +use OC\Authentication\Listeners\LoginFailedListener; use OC\Authentication\LoginCredentials\Store; use OC\Authentication\Token\IProvider; use OC\Avatar\AvatarManager; @@ -393,44 +396,44 @@ class Server extends ServerContainer implements IServerContainer { $this->registerService(\OCP\IGroupManager::class, function (Server $c) { $groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger()); $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); + \OC_Hook::emit('OC_Group', 'pre_createGroup', ['run' => true, 'gid' => $gid]); /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->query(IEventDispatcher::class); $dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid)); }); $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) { - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $group->getGID())); + \OC_Hook::emit('OC_User', 'post_createGroup', ['gid' => $group->getGID()]); /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->query(IEventDispatcher::class); $dispatcher->dispatchTyped(new GroupCreatedEvent($group)); }); $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', ['run' => true, 'gid' => $group->getGID()]); /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->query(IEventDispatcher::class); $dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group)); }); $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); + \OC_Hook::emit('OC_User', 'post_deleteGroup', ['gid' => $group->getGID()]); /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->query(IEventDispatcher::class); $dispatcher->dispatchTyped(new GroupDeletedEvent($group)); }); $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); + \OC_Hook::emit('OC_Group', 'pre_addToGroup', ['run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()]); /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->query(IEventDispatcher::class); $dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user)); }); $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); + \OC_Hook::emit('OC_Group', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]); //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); + \OC_Hook::emit('OC_User', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]); /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->query(IEventDispatcher::class); @@ -493,7 +496,7 @@ class Server extends ServerContainer implements IServerContainer { $c->query(IEventDispatcher::class) ); $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); + \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]); /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->query(IEventDispatcher::class); @@ -501,7 +504,7 @@ class Server extends ServerContainer implements IServerContainer { }); $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { /** @var $user \OC\User\User */ - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); + \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]); /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->query(IEventDispatcher::class); @@ -509,7 +512,7 @@ class Server extends ServerContainer implements IServerContainer { }); $userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) { /** @var $user \OC\User\User */ - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); + \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]); $legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); /** @var IEventDispatcher $dispatcher */ @@ -518,7 +521,7 @@ class Server extends ServerContainer implements IServerContainer { }); $userSession->listen('\OC\User', 'postDelete', function ($user) { /** @var $user \OC\User\User */ - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); + \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]); /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->query(IEventDispatcher::class); @@ -526,7 +529,7 @@ class Server extends ServerContainer implements IServerContainer { }); $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { /** @var $user \OC\User\User */ - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); + \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]); /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->query(IEventDispatcher::class); @@ -534,14 +537,14 @@ class Server extends ServerContainer implements IServerContainer { }); $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { /** @var $user \OC\User\User */ - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); + \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]); /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->query(IEventDispatcher::class); $dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword)); }); $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); + \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]); /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->query(IEventDispatcher::class); @@ -549,7 +552,7 @@ class Server extends ServerContainer implements IServerContainer { }); $userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) { /** @var $user \OC\User\User */ - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin)); + \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin]); /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->query(IEventDispatcher::class); @@ -562,14 +565,14 @@ class Server extends ServerContainer implements IServerContainer { }); $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { /** @var $user \OC\User\User */ - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); + \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]); /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->query(IEventDispatcher::class); $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password)); }); $userSession->listen('\OC\User', 'logout', function ($user) { - \OC_Hook::emit('OC_User', 'logout', array()); + \OC_Hook::emit('OC_User', 'logout', []); /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->query(IEventDispatcher::class); @@ -582,7 +585,7 @@ class Server extends ServerContainer implements IServerContainer { }); $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { /** @var $user \OC\User\User */ - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); + \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]); /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->query(IEventDispatcher::class); @@ -1420,6 +1423,10 @@ class Server extends ServerContainer implements IServerContainer { // no avatar to remove } }); + + /** @var IEventDispatcher $eventDispatched */ + $eventDispatched = $this->query(IEventDispatcher::class); + $eventDispatched->addServiceListener(LoginFailed::class, LoginFailedListener::class); } /** |