Refactor Security\Authentication class, remove dependency for App instance

This commit is contained in:
Art4 2024-11-06 13:21:57 +01:00
parent c0bd3b5ff0
commit 00d2e24dd2
8 changed files with 21 additions and 22 deletions

View file

@ -76,7 +76,6 @@ class Login extends BaseModule
if (!empty($request['auth-params']) && $request['auth-params'] === 'login') {
$this->auth->withPassword(
DI::app(),
trim($request['username']),
trim($request['password']),
!empty($request['remember']),

View file

@ -57,7 +57,7 @@ class OpenID extends BaseModule
// successful OpenID login
$session->remove('openid');
DI::auth()->setForUser(DI::app(), $user, true, true);
DI::auth()->setForUser($user, true, true);
$this->baseUrl->redirect(DI::session()->pop('return_path', ''));
}

View file

@ -59,7 +59,7 @@ class Recovery extends BaseModule
$this->session->set('2fa', true);
DI::sysmsg()->addInfo($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser($this->session->getLocalUserId())));
$this->auth->setForUser($this->app, User::getById($this->session->getLocalUserId()), true, true);
$this->auth->setForUser(User::getById($this->session->getLocalUserId()), true, true);
$this->baseUrl->redirect($this->session->pop('return_path', ''));
} else {

View file

@ -88,7 +88,7 @@ class Trust extends BaseModule
}
try {
$this->auth->setForUser($this->app, User::getById($this->session->getLocalUserId()), true, true);
$this->auth->setForUser(User::getById($this->session->getLocalUserId()), true, true);
$this->baseUrl->redirect($this->session->pop('return_path', ''));
} catch (FoundException | TemporaryRedirectException | MovedPermanentlyException $e) {
// exception wanted!
@ -109,7 +109,7 @@ class Trust extends BaseModule
try {
$trustedBrowser = $this->trustedBrowserRepository->selectOneByHash($this->cookie->get('2fa_cookie_hash'));
if (!$trustedBrowser->trusted) {
$this->auth->setForUser($this->app, User::getById($this->session->getLocalUserId()), true, true);
$this->auth->setForUser(User::getById($this->session->getLocalUserId()), true, true);
$this->baseUrl->redirect($this->session->pop('return_path', ''));
}
} catch (TrustedBrowserNotFoundException $exception) {

View file

@ -120,7 +120,7 @@ class Delegation extends BaseModule
$this->session->clear();
$this->auth->setForUser($this->app, $user, true, true);
$this->auth->setForUser($user, true, true);
if ($limited_id) {
$this->session->setSubManagedUserId($original_id);