Skip to content

Commit 341de11

Browse files
committed
switch to BeforeUserLoggedInEvent
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
1 parent 3832ad7 commit 341de11

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

lib/AppInfo/Application.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
use OCP\Security\Events\GenerateSecurePasswordEvent;
3636
use OCP\Security\Events\ValidatePasswordPolicyEvent;
3737
use OCP\User\Events\BeforePasswordUpdatedEvent;
38+
use OCP\User\Events\BeforeUserLoggedInEvent;
3839
use OCP\User\Events\PasswordUpdatedEvent;
39-
use OCP\User\Events\PostLoginEvent;
4040
use Symfony\Component\EventDispatcher\GenericEvent;
4141

4242
class Application extends App {
@@ -98,14 +98,14 @@ function (Event $event) use ($container) {
9898
}
9999
);
100100
$eventDispatcher->addListener(
101-
PostLoginEvent::class,
101+
BeforeUserLoggedInEvent::class,
102102
function (Event $event) use ($container) {
103-
if(!$event instanceof PostLoginEvent) {
103+
if(!$event instanceof BeforeUserLoggedInEvent) {
104104
return;
105105
}
106106
/** @var ComplianceService $complianceUpdater */
107107
$complianceUpdater = $container->query(ComplianceService::class);
108-
$complianceUpdater->entryControl($event->getUser(), $event->getPassword(), $event->isTokenLogin());
108+
$complianceUpdater->entryControl($event->getUsername(), $event->getPassword());
109109
}
110110
);
111111

lib/ComplianceService.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,15 @@ public function audit(IUser $user, string $password) {
8585
/**
8686
* @throws LoginException
8787
*/
88-
public function entryControl(IUser $user, string $password, bool $isTokenLogin) {
88+
//public function entryControl(IUser $user, string $password, bool $isTokenLogin) {
89+
public function entryControl(string $loginName, string $password) {
90+
$uid = $loginName;
91+
\OCP\Util::emitHook( '\OCA\Files_Sharing\API\Server2Server', 'preLoginNameUsedAsUserName', ['uid' => &$uid]);
8992
foreach ($this->getInstance(IEntryControl::class) as $instance) {
9093
try {
91-
$instance->entryControl($user, $password, $isTokenLogin);
94+
$user = \OC::$server->getUserManager()->get($uid);
95+
$instance->entryControl($user, $password, false);
9296
} catch (HintException $e) {
93-
if($this->userSession->isLoggedIn()) {
94-
$this->userSession->logout();
95-
}
9697
throw new LoginException($e->getHint());
9798
}
9899
}

0 commit comments

Comments
 (0)