MDL-84009 tool_mfa: Additional factor instances support
This commit is contained in:
@@ -169,6 +169,17 @@ switch ($action) {
|
||||
echo $OUTPUT->heading(get_string('managefactor', 'factor_' . $factorobject->name));
|
||||
echo $OUTPUT->active_factors($factor);
|
||||
echo $OUTPUT->single_button($returnurl, get_string('back'));
|
||||
|
||||
// Displays a setup additional button in case it is needed.
|
||||
if ($factorobject->show_additional_setup_button()) {
|
||||
echo $OUTPUT->single_button(
|
||||
url: new \moodle_url('action.php', ['action' => 'setup', 'factor' => $factor]),
|
||||
label: $factorobject->get_additional_setup_string(),
|
||||
method: 'post',
|
||||
options: ['type' => 'primary'],
|
||||
);
|
||||
}
|
||||
|
||||
// JS for modal confirming replace and revoke actions.
|
||||
$PAGE->requires->js_call_amd('tool_mfa/confirmation_modal', 'init', [$context->id]);
|
||||
|
||||
|
||||
@@ -421,6 +421,18 @@ abstract class object_factor_base implements object_factor {
|
||||
return $this->has_setup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a button should be shown to add factors of the same kind on the preferences page.
|
||||
* For example, give user's the ability to set up multiple security keys.
|
||||
*
|
||||
* Override in child class if necessary.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function show_additional_setup_button(): bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a factor requires input from the user to verify.
|
||||
*
|
||||
@@ -578,6 +590,18 @@ abstract class object_factor_base implements object_factor {
|
||||
return get_string('setupfactor', 'tool_mfa');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string for additional setup button on preferences page.
|
||||
* If the user has the ability to set up multiple security keys.
|
||||
*
|
||||
* Override in child class if necessary.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_additional_setup_string(): string {
|
||||
return get_string('setupfactorbuttonadditional', 'tool_mfa');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string for manage button on preferences page.
|
||||
*
|
||||
|
||||
@@ -151,6 +151,7 @@ $string['settings:redir_exclusions_help'] = 'Each new line is a relative URL fro
|
||||
$string['settings:weight'] = 'Factor weight';
|
||||
$string['settings:weight_help'] = 'The weight of this factor if passed. A user needs at least 100 points to log in.';
|
||||
$string['setupfactor'] = 'Set up factor';
|
||||
$string['setupfactorbuttonadditional'] = 'Add additional factor';
|
||||
$string['setuprequired'] = 'User setup';
|
||||
$string['state:fail'] = 'Fail';
|
||||
$string['state:locked'] = 'Locked';
|
||||
|
||||
Reference in New Issue
Block a user