' . $this->i18n('2fa_status_email_info', rex::getUser()->getLogin(), rex::getUser()->getEmail()) . '
'; 83 | break; 84 | default: 85 | $content = '' . $this->i18n('2fa_status_otp_info', rex::getUser()->getLogin()) . '
'; 86 | break; 87 | } 88 | $this->i18n('2fa_status_otp_instruction'); 89 | $content .= '' . $this->i18n('2fa_disable', rex::getUser()->getLogin()) . '
'; 90 | } else { 91 | if ('' === $func) { 92 | if (one_time_password::OPTION_ALL == $otp_options || one_time_password::OPTION_TOTP == $otp_options) { 93 | $content .= '' . $this->i18n('2factor_auth_2fa_page_totp_instruction') . '
'; 94 | $content .= '' . $this->i18n('2fa_setup_start_totp') . '
'; 95 | } 96 | if (one_time_password::OPTION_ALL == $otp_options || one_time_password::OPTION_EMAIL == $otp_options) { 97 | $content .= '' . $this->i18n('2factor_auth_2fa_page_email_instruction') . '
'; 98 | $content .= '' . $this->i18n('2fa_setup_start_email') . '
'; 99 | } 100 | } elseif ('setup-totp' === $func) { 101 | // nothing todo 102 | } elseif ('setup-email' === $func) { 103 | if (!rex_addon::get('phpmailer')->isAvailable()) { 104 | $content = rex_view::error($this->i18n('2fa_setup_start_phpmailer_required')); 105 | $func = ''; 106 | } 107 | 108 | $email = trim(rex::requireUser()->getEmail()); 109 | if ('' !== $func && ('' === $email || !str_contains($email, '@'))) { 110 | $content = rex_view::error($this->i18n('2fa_setup_start_email_required')); 111 | $buttons = '' . $this->i18n('2fa_setup_start_email_open_profile') . ''; 112 | 113 | $func = ''; 114 | } 115 | 116 | if ('' !== $func) { 117 | try { 118 | one_time_password::getInstance()->challenge(); 119 | $message = rex_view::info($this->i18n('2fa_setup_start_email_send')); 120 | } catch (Exception $e) { 121 | $message = rex_view::error($e->getMessage()); 122 | $func = ''; 123 | } 124 | } 125 | } elseif ('verify-totp' === $func || 'verify-email' === $func) { 126 | $otp = rex_post('rex_login_otp', 'string', ''); 127 | 128 | if ('' !== $otp) { 129 | if (one_time_password::getInstance()->verify($otp)) { 130 | $message = 'id | '; 27 | $content .= 'login | '; 28 | $content .= 'status | '; 29 | $content .= 'method | '; 30 | $content .= 'tries | '; 31 | $content .= 'last_try | '; 32 | $content .= 'actions | '; 33 | $content .= '
---|---|---|---|---|---|---|
' . rex_escape($user->getId()) . ' | 44 |' . rex_escape($user->getLogin()) . ' | 45 |' . rex_escape($config->enabled ? 'on' : 'off') . ' | 46 |' . rex_escape($config->method) . ' | 47 |' . rex_escape($user->getValue('one_time_password_tries')) . ' | 48 |' . rex_escape($user->getValue('one_time_password_lasttry')) . ' | 49 |deactivate | 50 |
22 | */ 23 | function trigger_deprecation(string $package, string $version, string $message, mixed ...$args): void 24 | { 25 | @trigger_error(($package || $version ? "Since $package $version: " : '').($args ? vsprintf($message, $args) : $message), \E_USER_DEPRECATED); 26 | } 27 | } 28 | --------------------------------------------------------------------------------