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

@ -25,6 +25,7 @@ use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\Response;
use Friendica\Security\TwoFactor\Model\AppSpecificPassword;
use Friendica\Module\BaseSettings;
@ -61,7 +62,7 @@ class AppSpecific extends BaseSettings
}
if (!self::checkFormSecurityToken('settings_2fa_password', 't')) {
notice($this->t('Please enter your password to access this page.'));
DI::sysmsg()->addNotice($this->t('Please enter your password to access this page.'));
$this->baseUrl->redirect('settings/2fa');
}
}
@ -79,20 +80,20 @@ class AppSpecific extends BaseSettings
case 'generate':
$description = $_POST['description'] ?? '';
if (empty($description)) {
notice($this->t('App-specific password generation failed: The description is empty.'));
DI::sysmsg()->addNotice($this->t('App-specific password generation failed: The description is empty.'));
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
} elseif (AppSpecificPassword::checkDuplicateForUser(local_user(), $description)) {
notice($this->t('App-specific password generation failed: This description already exists.'));
DI::sysmsg()->addNotice($this->t('App-specific password generation failed: This description already exists.'));
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
} else {
$this->appSpecificPassword = AppSpecificPassword::generateForUser(local_user(), $_POST['description'] ?? '');
info($this->t('New app-specific password generated.'));
DI::sysmsg()->addInfo($this->t('New app-specific password generated.'));
}
break;
case 'revoke_all' :
AppSpecificPassword::deleteAllForUser(local_user());
info($this->t('App-specific passwords successfully revoked.'));
DI::sysmsg()->addInfo($this->t('App-specific passwords successfully revoked.'));
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
break;
}
@ -102,7 +103,7 @@ class AppSpecific extends BaseSettings
self::checkFormSecurityTokenRedirectOnError('settings/2fa/app_specific', 'settings_2fa_app_specific');
if (AppSpecificPassword::deleteForUser(local_user(), $_POST['revoke_id'])) {
info($this->t('App-specific password successfully revoked.'));
DI::sysmsg()->addInfo($this->t('App-specific password successfully revoked.'));
}
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));

View file

@ -66,7 +66,7 @@ class Index extends BaseSettings
DI::pConfig()->delete(local_user(), '2fa', 'verified');
Session::remove('2fa');
info(DI::l10n()->t('Two-factor authentication successfully disabled.'));
DI::sysmsg()->addInfo(DI::l10n()->t('Two-factor authentication successfully disabled.'));
DI::baseUrl()->redirect('settings/2fa');
}
break;
@ -98,7 +98,7 @@ class Index extends BaseSettings
} catch (FoundException $exception) {
// Nothing to do here
} catch (\Exception $e) {
notice(DI::l10n()->t($e->getMessage()));
DI::sysmsg()->addNotice(DI::l10n()->t($e->getMessage()));
}
}

View file

@ -25,6 +25,7 @@ use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\Response;
use Friendica\Security\TwoFactor\Model\RecoveryCode;
use Friendica\Module\BaseSettings;
@ -59,7 +60,7 @@ class Recovery extends BaseSettings
}
if (!self::checkFormSecurityToken('settings_2fa_password', 't')) {
notice($this->t('Please enter your password to access this page.'));
DI::sysmsg()->addNotice($this->t('Please enter your password to access this page.'));
$this->baseUrl->redirect('settings/2fa');
}
}
@ -75,7 +76,7 @@ class Recovery extends BaseSettings
if ($_POST['action'] == 'regenerate') {
RecoveryCode::regenerateForUser(local_user());
info($this->t('New recovery codes successfully generated.'));
DI::sysmsg()->addInfo($this->t('New recovery codes successfully generated.'));
$this->baseUrl->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password'));
}
}

View file

@ -25,6 +25,7 @@ use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseSettings;
use Friendica\Module\Response;
use Friendica\Security\TwoFactor;
@ -62,7 +63,7 @@ class Trusted extends BaseSettings
}
if (!self::checkFormSecurityToken('settings_2fa_password', 't')) {
notice($this->t('Please enter your password to access this page.'));
DI::sysmsg()->addNotice($this->t('Please enter your password to access this page.'));
$this->baseUrl->redirect('settings/2fa');
}
}
@ -79,7 +80,7 @@ class Trusted extends BaseSettings
switch ($_POST['action']) {
case 'remove_all':
$this->trustedBrowserRepo->removeAllForUser(local_user());
info($this->t('Trusted browsers successfully removed.'));
DI::sysmsg()->addInfo($this->t('Trusted browsers successfully removed.'));
$this->baseUrl->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password'));
break;
}
@ -89,7 +90,7 @@ class Trusted extends BaseSettings
self::checkFormSecurityTokenRedirectOnError('settings/2fa/trusted', 'settings_2fa_trusted');
if ($this->trustedBrowserRepo->removeForUser(local_user(), $_POST['remove_id'])) {
info($this->t('Trusted browser successfully removed.'));
DI::sysmsg()->addInfo($this->t('Trusted browser successfully removed.'));
}
$this->baseUrl->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password'));

View file

@ -30,6 +30,7 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\BaseSettings;
use Friendica\Module\Response;
use Friendica\Module\Security\Login;
@ -65,7 +66,7 @@ class Verify extends BaseSettings
}
if (!self::checkFormSecurityToken('settings_2fa_password', 't')) {
notice($this->t('Please enter your password to access this page.'));
DI::sysmsg()->addNotice($this->t('Please enter your password to access this page.'));
$this->baseUrl->redirect('settings/2fa');
}
}
@ -87,11 +88,11 @@ class Verify extends BaseSettings
$this->pConfig->set(local_user(), '2fa', 'verified', true);
Session::set('2fa', true);
info($this->t('Two-factor authentication successfully activated.'));
DI::sysmsg()->addInfo($this->t('Two-factor authentication successfully activated.'));
$this->baseUrl->redirect('settings/2fa');
} else {
notice($this->t('Invalid code, please retry.'));
DI::sysmsg()->addNotice($this->t('Invalid code, please retry.'));
}
}
}