mirror of
https://github.com/friendica/friendica
synced 2025-04-24 01:50:17 +00:00
old boot.php functions replaced in src/module (4)
This commit is contained in:
parent
de6eabde58
commit
d47d78f2d4
22 changed files with 140 additions and 158 deletions
|
@ -25,6 +25,7 @@ use Friendica\App;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User;
|
||||
|
@ -59,7 +60,7 @@ class Recovery extends BaseModule
|
|||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!local_user()) {
|
||||
if (!Session::getLocalUser()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -68,10 +69,10 @@ class Recovery extends BaseModule
|
|||
|
||||
$recovery_code = $_POST['recovery_code'] ?? '';
|
||||
|
||||
if (RecoveryCode::existsForUser(local_user(), $recovery_code)) {
|
||||
RecoveryCode::markUsedForUser(local_user(), $recovery_code);
|
||||
if (RecoveryCode::existsForUser(Session::getLocalUser(), $recovery_code)) {
|
||||
RecoveryCode::markUsedForUser(Session::getLocalUser(), $recovery_code);
|
||||
$this->session->set('2fa', true);
|
||||
DI::sysmsg()->addInfo($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(local_user())));
|
||||
DI::sysmsg()->addInfo($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(Session::getLocalUser())));
|
||||
|
||||
$this->auth->setForUser($this->app, User::getById($this->app->getLoggedInUserId()), true, true);
|
||||
|
||||
|
@ -84,7 +85,7 @@ class Recovery extends BaseModule
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!local_user()) {
|
||||
if (!Session::getLocalUser()) {
|
||||
$this->baseUrl->redirect();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\App;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User\Cookie;
|
||||
|
@ -61,7 +62,7 @@ class SignOut extends BaseModule
|
|||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!local_user() || !($this->cookie->get('2fa_cookie_hash'))) {
|
||||
if (!Session::getLocalUser() || !($this->cookie->get('2fa_cookie_hash'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -80,7 +81,7 @@ class SignOut extends BaseModule
|
|||
$this->baseUrl->redirect();
|
||||
break;
|
||||
case 'sign_out':
|
||||
$this->trustedBrowserRepository->removeForUser(local_user(), $this->cookie->get('2fa_cookie_hash'));
|
||||
$this->trustedBrowserRepository->removeForUser(Session::getLocalUser(), $this->cookie->get('2fa_cookie_hash'));
|
||||
$this->cookie->clear();
|
||||
$this->session->clear();
|
||||
|
||||
|
@ -95,7 +96,7 @@ class SignOut extends BaseModule
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!local_user() || !($this->cookie->get('2fa_cookie_hash'))) {
|
||||
if (!Session::getLocalUser() || !($this->cookie->get('2fa_cookie_hash'))) {
|
||||
$this->baseUrl->redirect();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\App;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User;
|
||||
|
@ -74,7 +75,7 @@ class Trust extends BaseModule
|
|||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!local_user() || !$this->session->get('2fa')) {
|
||||
if (!Session::getLocalUser() || !$this->session->get('2fa')) {
|
||||
$this->logger->info('Invalid call', ['request' => $request]);
|
||||
return;
|
||||
}
|
||||
|
@ -87,7 +88,7 @@ class Trust extends BaseModule
|
|||
switch ($action) {
|
||||
case 'trust':
|
||||
case 'dont_trust':
|
||||
$trustedBrowser = $this->trustedBrowserFactory->createForUserWithUserAgent(local_user(), $this->server['HTTP_USER_AGENT'], $action === 'trust');
|
||||
$trustedBrowser = $this->trustedBrowserFactory->createForUserWithUserAgent(Session::getLocalUser(), $this->server['HTTP_USER_AGENT'], $action === 'trust');
|
||||
try {
|
||||
$this->trustedBrowserRepository->save($trustedBrowser);
|
||||
|
||||
|
@ -115,7 +116,7 @@ class Trust extends BaseModule
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!local_user() || !$this->session->get('2fa')) {
|
||||
if (!Session::getLocalUser() || !$this->session->get('2fa')) {
|
||||
$this->baseUrl->redirect();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ use Friendica\BaseModule;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Util\Profiler;
|
||||
|
@ -57,7 +58,7 @@ class Verify extends BaseModule
|
|||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!local_user()) {
|
||||
if (!Session::getLocalUser()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -66,7 +67,7 @@ class Verify extends BaseModule
|
|||
|
||||
$code = $request['verify_code'] ?? '';
|
||||
|
||||
$valid = (new Google2FA())->verifyKey($this->pConfig->get(local_user(), '2fa', 'secret'), $code);
|
||||
$valid = (new Google2FA())->verifyKey($this->pConfig->get(Session::getLocalUser(), '2fa', 'secret'), $code);
|
||||
|
||||
// The same code can't be used twice even if it's valid
|
||||
if ($valid && $this->session->get('2fa') !== $code) {
|
||||
|
@ -81,7 +82,7 @@ class Verify extends BaseModule
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!local_user()) {
|
||||
if (!Session::getLocalUser()) {
|
||||
$this->baseUrl->redirect();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue