Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

MFA factor interface.

Author: Mikhail Golenkov <golenkovm@gmail.com>
Copyright: Catalyst IT
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 316 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Interface: object_factor  - X-Ref

is_enabled()   X-Ref
Returns true if factor is enabled, otherwise false.

return: bool

get_weight()   X-Ref
Returns configured factor weight.

return: int

get_display_name()   X-Ref
Returns factor name from language string.

return: string

get_info()   X-Ref
Returns factor info from language string.

return: string

setup_factor_form_definition(\MoodleQuickForm $mform)   X-Ref
Defines setup_factor form definition page for particular factor.

param: \MoodleQuickForm $mform
return: object $mform

setup_factor_form_definition_after_data(\MoodleQuickForm $mform)   X-Ref
Defines setup_factor form definition page after form data has been set.

param: \MoodleQuickForm $mform
return: object $mform

setup_factor_form_validation(array $data)   X-Ref
Implements setup_factor form validation for particular factor.
Returns an array of errors, where array key = field id and array value = error text.

param: array $data
return: array

login_form_definition(\MoodleQuickForm $mform)   X-Ref
Defines login form definition page for particular factor.

param: \MoodleQuickForm $mform
return: object $mform

login_form_definition_after_data(\MoodleQuickForm $mform)   X-Ref
Defines login form definition page after form data has been set.

param: \MoodleQuickForm $mform
return: object $mform

login_form_validation(array $data)   X-Ref
Implements login form validation for particular factor.
Returns an array of errors, where array key = field id and array value = error text.

param: array $data
return: array

setup_user_factor(stdClass $data)   X-Ref
Setups given factor and adds it to user's active factors list.
Returns true if factor has been successfully added, otherwise false.

param: stdClass $data
return: stdClass|null the factor record, or null.

get_all_user_factors(stdClass $user)   X-Ref
Returns an array of all user factors of given type (both active and revoked).

param: stdClass $user the user to check against.
return: array

get_active_user_factors(stdClass $user)   X-Ref
Returns an array of active user factor records.
Filters get_all_user_factors() output.

param: stdClass $user the user to check against.
return: array

has_revoke()   X-Ref
Returns true if factor class has factor records that might be revoked.
It means that user can revoke factor record from their profile.

return: bool

revoke_user_factor(?int $factorid = null)   X-Ref
Marks factor record as revoked.
If factorid is not provided, revoke all instances of factor.

param: int|null $factorid
return: bool

update_lastverified(?int $factorid = null)   X-Ref
When validation code is correct - update lastverified field for given factor.
If factor id is not provided, update all factor entries for user.

param: int|null $factorid
return: bool|\dml_exception

get_lastverified(int $factorid)   X-Ref
Gets lastverified timestamp.

param: int $factorid
return: int|bool

has_setup()   X-Ref
Returns true if factor needs to be setup by user and has setup_form.

return: bool

show_setup_buttons()   X-Ref
If has_setup returns true, decides if the setup buttons should be shown on the preferences page.

return: bool

has_input()   X-Ref
Returns true if factor requires user input for success or failure during login.

return: bool

get_state()   X-Ref
Returns the state of the factor check

return: string

set_state(string $state)   X-Ref
Sets the state of the factor check into the session.
Returns whether storing the var was successful.

param: string $state
return: bool

post_pass_state()   X-Ref
Fires any additional actions required by the factor once the user reaches the pass state.

return: void

get_label(int $factorid)   X-Ref
Retrieves label for a factorid.

param: int $factorid
return: string|\dml_exception

get_no_redirect_urls()   X-Ref
Returns a list of urls to not redirect from.

return: array

possible_states(stdClass $user)   X-Ref
Returns all possible states for a user.

param: stdClass $user
return: array

get_summary_condition()   X-Ref
Return summary condition for passing factor.

return: string

check_combination(array $combination)   X-Ref
Checks whether the factor combination is valid based on factor behaviour.
E.g. a combination with nosetup and another factor is not valid,
as you cannot pass nosetup with another factor.

param: array $combination array of factors that make up the combination
return: bool

get_setup_string()   X-Ref
Gets the string for setup button on preferences page.

return: string the string to display on the button.

delete_factor_for_user(stdClass $user)   X-Ref
Deletes all instances of a factor for user.

param: stdClass $user the user to delete for.
return: void

process_cancel_action()   X-Ref
Process a cancel action from a user.

return: void

global_definition(\MoodleQuickForm $mform)   X-Ref
Hook point for global auth form action hooks.

param: \MoodleQuickForm $mform Form to inject global elements into.
return: void

global_definition_after_data(\MoodleQuickForm $mform)   X-Ref
Hook point for global auth form action hooks.

param: \MoodleQuickForm $mform Form to inject global elements into.
return: void

global_validation(array $data, array $files)   X-Ref
Hook point for global auth form action hooks.

param: array $data Data from the form.
param: array $files Files form the form.
return: array of errors from validation.

global_submit(object $data)   X-Ref
Hook point for global auth form action hooks.

param: object $data Data from the form.
return: void