diff --git a/lang/en/auth_emailotp.php b/lang/en/auth_emailotp.php
index 6b87c64..33099c3 100644
--- a/lang/en/auth_emailotp.php
+++ b/lang/en/auth_emailotp.php
@@ -31,11 +31,12 @@ $string['otpsentsuccess'] = 'One-time password was sent to given email.';
$string['otpsenterror'] = 'An error occurred while sending one-time password.';
$string['otpsentinfo'] = 'One-time password for current session was already generated and sent to email.';
$string['otprevoked'] = 'Previously generated password has been revoked due to exceeding the login failure threshold.';
-$string['otpperioderror'] = 'Minim period after which another password can be generated not preserved. Try again later.';
+$string['otpperiodwarning'] = 'Minim period after which another password can be generated not preserved. Try again later.';
$string['revokethreshold'] = 'Revoke threshold';
$string['revokethreshold_help'] = 'Login failures limit causing revoke of the generated password (0 - unlimited).';
$string['minrequestperiod'] = 'Minium period';
-$string['minrequestperiod_help'] = 'A time in seconds after which another password can be generated.';
+$string['minrequestperiod_help'] = 'A time in seconds after which another password can be generated (0 - unrestricted). Enabled logstore required.';
+$string['logstorerequired'] = 'Notice: no working logstore! Enable logstore or set time to 0.';
$string['fieldsmapping'] = 'User profile fields mapping';
$string['fieldsmapping_pattern'] = 'Pattern';
$string['fieldsmapping_pattern_help'] = 'Capturing groups PCRE pattern.';
@@ -46,11 +47,12 @@ $string['fieldsmapping_help'] = <<<'EOT'
Pattern:
-'#/?PMapping:[^\.]+)\.(?P [^@]+)@(?P [^\.]+).*#', +'#/?P<FIRST>[^\.]+)\.(?P<LAST>[^@]+)@(?P<COMPANY>[^\.]+).*#',
+username:FIRST_LAST firstname:FIRST:ucfirst lastname:LAST:ucfirst institution:COMPANY:strtoupper @@ -58,9 +60,11 @@ institution:COMPANY:strtouppermaps my.name@corp.com to:
+username: my_name
firstname: My
lastname: Name
institution: CORP
-Allowed modifiers: ucfirst, ucwords, strtoupper.
+Allowed modifiers: ucfirst, ucwords, strtoupper. Without mapping of +username field whole email address is taken as username.
EOT; diff --git a/lang/pl/auth_emailotp.php b/lang/pl/auth_emailotp.php index f1e55e5..61f41fc 100644 --- a/lang/pl/auth_emailotp.php +++ b/lang/pl/auth_emailotp.php @@ -31,11 +31,12 @@ $string['otpsentsuccess'] = 'Hasło jednorazowe zostało wysłane na podany adre $string['otpsenterror'] = 'Wystąpił błąd podczas wysyłania hasła jednorazowego.'; $string['otpsentinfo'] = 'Hasło jednorazowe dla bieżącej sesji już zostało wygenerowane i wysłane.'; $string['otpinvalidated'] = 'Poprzednio wygenerowane hasło zostało unieważnione z powodu przekroczenia limitu niepoprawnych logowań.'; -$string['otpperioderror'] = 'Nie zachowany minimalny odstęp, po którym kolejne hasło może być wygenerowane. Spróbuj ponownie później.'; +$string['otpperiodwarning'] = 'Nie zachowany minimalny odstęp, po którym kolejne hasło może być wygenerowane. Spróbuj ponownie później.'; $string['revokethreshold'] = 'Próg nieważnienia'; $string['revokethreshold_help'] = 'Limit nieudanych logowań unieważniających wygenerowane hasło (0 - bez limitu).'; $string['minrequestperiod'] = 'Minimalny odstęp'; -$string['minrequestperiod_help'] = 'Czas w sekundach, po którym kolejne hasło może być wygenerowane.'; +$string['minrequestperiod_help'] = 'Czas w sekundach, po którym kolejne hasło może być wygenerowane (0 - nieograniczony). Wymaga działającego loggera.'; +$string['logstorerequired'] = 'Uwaga: logger nieaktywny! Aktywuj logger albo ustaw czas na 0.'; $string['fieldsmapping'] = 'Mapowanie pól profilu użytkownika'; $string['fieldsmapping_pattern'] = 'Wzorzec'; $string['fieldsmapping_pattern_help'] = 'Grupujące wyrażenie regularne PCRE.'; @@ -46,11 +47,12 @@ $string['fieldsmapping_help'] = <<<'EOT' Wzorzec:
-'#/?PMapowanie:[^\.]+)\.(?P [^@]+)@(?P [^\.]+).*#', +'#/?P<FIRST>[^\.]+)\.(?P<LAST>[^@]+)@(?P<COMPANY>[^\.]+).*#',
+username:FIRST_LAST firstname:FIRST:ucfirst lastname:LAST:ucfirst institution:COMPANY:strtoupper @@ -58,9 +60,12 @@ institution:COMPANY:strtoupperodwzoruje my.name@corp.com na:
+username: my_name
firstname: My
lastname: Name
institution: CORP
-Dozwolone modyfikatory: ucfirst, ucwords, strtoupper.
+Dozwolone modyfikatory: ucfirst, ucwords, strtoupper. Przy braku mapowania +pola username domyślnie cały adres email jest traktowany jako nazwa +użytkownika.
EOT; diff --git a/settings.php b/settings.php index 1a10d61..48c260c 100644 --- a/settings.php +++ b/settings.php @@ -53,15 +53,27 @@ if ($ADMIN->fulltree) { get_string('fieldsmapping_mapping_help', 'auth_emailotp'), '', PARAM_RAW_TRIMMED)); $settings->add(new admin_setting_heading('auth_emailotp/security', - new lang_string('security', 'admin'), '')); + new lang_string('security', 'admin'), '')); $settings->add(new admin_setting_configtext('auth_emailotp/revokethreshold', get_string('revokethreshold', 'auth_emailotp'), get_string('revokethreshold_help', 'auth_emailotp'), 3, PARAM_INT)); - $settings->add(new admin_setting_configtext('auth_emailotp/minrequestperiod', + $settings->add(new class( + 'auth_emailotp/minrequestperiod', get_string('minrequestperiod', 'auth_emailotp'), - get_string('minrequestperiod_help', 'auth_emailotp'), 120, PARAM_INT)); + get_string('minrequestperiod_help', 'auth_emailotp') + ) extends admin_setting_configtext { + public function __construct($name, $visiblename, $description) { + $log_reader = reset(get_log_manager()->get_readers('\core\log\sql_reader')); + parent::__construct($name, $visiblename, $description, $log_reader ? 120 : 0, PARAM_INT); + if(!$log_reader && !empty($this->get_setting())) { + $this->description .= ' '.get_string('logstorerequired', 'auth_emailotp', + (string)new moodle_url('/admin/settings.php', ['section' => 'managelogging']) + ); + } + } + }); // Display locking / mapping of profile fields. $authplugin = get_auth_plugin('emailotp'); diff --git a/version.php b/version.php index 9f6d5b5..f424e34 100644 --- a/version.php +++ b/version.php @@ -24,8 +24,8 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2020111004; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2020111800; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2018120304; // Requires this Moodle version. $plugin->component = 'auth_emailotp'; // Full name of the plugin (used for diagnostics). -$plugin->maturity = MATURITY_STABLE; -$plugin->release = '1.0.2'; +$plugin->maturity = MATURITY_ALPHA; +$plugin->release = '1.1.0';