Replace deprecated defaults() calls by ?? and ?: operators in src/Module/

This commit is contained in:
Hypolite Petovan 2019-10-15 09:20:32 -04:00
parent 8998926e5b
commit f59ea2af55
40 changed files with 115 additions and 94 deletions

View file

@ -26,12 +26,12 @@ class Index extends BaseSettingsModule
self::checkFormSecurityTokenRedirectOnError('settings/2fa', 'settings_2fa');
try {
User::getIdFromPasswordAuthentication(local_user(), defaults($_POST, 'password', ''));
User::getIdFromPasswordAuthentication(local_user(), $_POST['password'] ?? '');
$has_secret = (bool) PConfig::get(local_user(), '2fa', 'secret');
$verified = PConfig::get(local_user(), '2fa', 'verified');
switch (defaults($_POST, 'action', '')) {
switch ($_POST['action'] ?? '') {
case 'enable':
if (!$has_secret && !$verified) {
$Google2FA = new Google2FA();

View file

@ -49,12 +49,12 @@ class Verify extends BaseSettingsModule
return;
}
if (defaults($_POST, 'action', null) == 'verify') {
if (($_POST['action'] ?? '') == 'verify') {
self::checkFormSecurityTokenRedirectOnError('settings/2fa/verify', 'settings_2fa_verify');
$google2fa = new Google2FA();
$valid = $google2fa->verifyKey(PConfig::get(local_user(), '2fa', 'secret'), defaults($_POST, 'verify_code', ''));
$valid = $google2fa->verifyKey(PConfig::get(local_user(), '2fa', 'secret'), $_POST['verify_code'] ?? '');
if ($valid) {
PConfig::set(local_user(), '2fa', 'verified', true);