Merge branch 'MDL-84275-405' of https://github.com/paulholden/moodle into MOODLE_405_STABLE
This commit is contained in:
@@ -34,6 +34,7 @@ use tool_mfa\local\factor\object_factor_base;
|
||||
use OTPHP\TOTP;
|
||||
use stdClass;
|
||||
use core\clock;
|
||||
use core\context\system;
|
||||
use core\di;
|
||||
|
||||
/**
|
||||
@@ -90,7 +91,7 @@ class factor extends object_factor_base {
|
||||
public function generate_totp_uri(string $secret): string {
|
||||
global $USER, $SITE, $CFG;
|
||||
$host = parse_url($CFG->wwwroot, PHP_URL_HOST);
|
||||
$sitename = str_replace(':', '', $SITE->fullname);
|
||||
$sitename = str_replace(':', '', format_string($SITE->fullname, true, ['context' => system::instance()]));
|
||||
$issuer = $sitename.' '.$host;
|
||||
$totp = TOTP::create($secret, clock: $this->clock);
|
||||
$totp->setLabel($USER->username);
|
||||
@@ -190,13 +191,15 @@ class factor extends object_factor_base {
|
||||
$secret = wordwrap($secret, 4, ' ', true) . '</code>';
|
||||
$secret = \html_writer::tag('code', $secret);
|
||||
|
||||
$sitefullname = format_string($SITE->fullname, true, ['context' => system::instance()]);
|
||||
|
||||
$manualtable = new \html_table();
|
||||
$manualtable->id = 'manualattributes';
|
||||
$manualtable->attributes['class'] = 'generaltable table table-bordered table-sm w-auto';
|
||||
$manualtable->attributes['style'] = 'width: auto;';
|
||||
$manualtable->data = [
|
||||
[get_string('setupfactor:key', 'factor_totp'), $secret],
|
||||
[get_string('setupfactor:account', 'factor_totp'), "$SITE->fullname ($USER->username)"],
|
||||
[get_string('setupfactor:account', 'factor_totp'), "{$sitefullname} ({$USER->username})"],
|
||||
[get_string('setupfactor:mode', 'factor_totp'), get_string('setupfactor:mode:timebased', 'factor_totp')],
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user