Skip to content

Commit

Permalink
Move to UserLoggedInEvent for login checks (#46)
Browse files Browse the repository at this point in the history
Fixes #42
  • Loading branch information
stjosh authored May 19, 2020
1 parent b51c141 commit 0cef2be
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Move to UserLoggedInEvent for login checks, enabling compatibility with SAML login [#42](https://github.com/stjosh/auto_groups/issues/42)

## 1.1.1 - 2020-05-08
### Changed
Expand Down
4 changes: 2 additions & 2 deletions lib/AutoGroupsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
namespace OCA\AutoGroups;

use OCP\User\Events\UserCreatedEvent;
use OCP\User\Events\PostLoginEvent;
use OCP\User\Events\UserLoggedInEvent;
use OCP\Group\Events\UserAddedEvent;
use OCP\Group\Events\UserRemovedEvent;
use OCP\Group\Events\BeforeGroupDeletedEvent;
Expand Down Expand Up @@ -69,7 +69,7 @@ public function __construct(IGroupManager $groupManager, IEventDispatcher $event

// If login hook is enabled, add user to / remove user from auto groups on every successful login
if (filter_var($loginHook, FILTER_VALIDATE_BOOLEAN)) {
$eventDispatcher->addListener(PostLoginEvent::class, $groupAssignmentCallback);
$eventDispatcher->addListener(UserLoggedInEvent::class, $groupAssignmentCallback);
}

// Handle group deletion events
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/AutoGroupsManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
namespace OCA\AutoGroups\Tests\Unit;

use OCP\User\Events\UserCreatedEvent;
use OCP\User\Events\PostLoginEvent;
use OCP\User\Events\UserLoggedInEvent;
use OCP\Group\Events\UserAddedEvent;
use OCP\Group\Events\UserRemovedEvent;
use OCP\Group\Events\BeforeGroupDeletedEvent;
Expand Down Expand Up @@ -121,7 +121,7 @@ public function testAlsoLoginHookIfEnabled()
[UserCreatedEvent::class, $this->callback('is_callable')],
[UserAddedEvent::class, $this->callback('is_callable')],
[UserRemovedEvent::class, $this->callback('is_callable')],
[PostLoginEvent::class, $this->callback('is_callable')],
[UserLoggedInEvent::class, $this->callback('is_callable')],
[BeforeGroupDeletedEvent::class, $this->callback('is_callable')]
);

Expand Down

0 comments on commit 0cef2be

Please sign in to comment.