The notice and info have been moved

This commit is contained in:
Michael 2022-10-17 18:55:22 +00:00
parent 20291ddc2b
commit fdfa1f8630
73 changed files with 273 additions and 284 deletions

View file

@ -26,6 +26,7 @@ use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Module\Response;
use Friendica\Security\Authentication;
@ -70,13 +71,13 @@ class Recovery extends BaseModule
if (RecoveryCode::existsForUser(local_user(), $recovery_code)) {
RecoveryCode::markUsedForUser(local_user(), $recovery_code);
$this->session->set('2fa', true);
info($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(local_user())));
DI::sysmsg()->addInfo($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(local_user())));
$this->auth->setForUser($this->app, User::getById($this->app->getLoggedInUserId()), true, true);
$this->baseUrl->redirect($this->session->pop('return_path', ''));
} else {
notice($this->t('Invalid code, please retry.'));
DI::sysmsg()->addNotice($this->t('Invalid code, please retry.'));
}
}
}

View file

@ -26,6 +26,7 @@ use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\DI;
use Friendica\Model\User\Cookie;
use Friendica\Module\Response;
use Friendica\Network\HTTPException\NotFoundException;
@ -75,7 +76,7 @@ class SignOut extends BaseModule
$this->cookie->reset(['2fa_cookie_hash' => $trusted]);
$this->session->clear();
info($this->t('Logged out.'));
DI::sysmsg()->addInfo($this->t('Logged out.'));
$this->baseUrl->redirect();
break;
case 'sign_out':
@ -83,7 +84,7 @@ class SignOut extends BaseModule
$this->cookie->clear();
$this->session->clear();
info($this->t('Logged out.'));
DI::sysmsg()->addInfo($this->t('Logged out.'));
$this->baseUrl->redirect();
break;
default:
@ -105,14 +106,14 @@ class SignOut extends BaseModule
$this->cookie->reset(['2fa_cookie_hash' => $trusted]);
$this->session->clear();
info($this->t('Logged out.'));
DI::sysmsg()->addInfo($this->t('Logged out.'));
$this->baseUrl->redirect();
}
} catch (TwoFactor\Exception\TrustedBrowserNotFoundException $exception) {
$this->cookie->clear();
$this->session->clear();
info($this->t('Logged out.'));
DI::sysmsg()->addInfo($this->t('Logged out.'));
$this->baseUrl->redirect();
}

View file

@ -26,6 +26,7 @@ use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Model\User\Cookie;
use Friendica\Module\Response;
@ -92,7 +93,7 @@ class Trust extends BaseModule
// The string is sent to the browser to be sent back with each request
if (!$this->cookie->set('2fa_cookie_hash', $trustedBrowser->cookie_hash)) {
notice($this->t('Couldn\'t save browser to Cookie.'));
DI::sysmsg()->addNotice($this->t('Couldn\'t save browser to Cookie.'));
};
} catch (TrustedBrowserPersistenceException $exception) {
$this->logger->warning('Unexpected error when saving the trusted browser.', ['trustedBrowser' => $trustedBrowser, 'exception' => $exception]);