Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
factor_grace\factor Class Reference
Inheritance diagram for factor_grace\factor:
tool_mfa\local\factor\object_factor_base tool_mfa\local\factor\object_factor

Public Member Functions

 check_combination (array $combination)
 Grace Factor implementation.
 
 create_event_after_factor_setup (object $user)
 Creates an event when user successfully setup a factor.
 
 delete_factor_for_user (stdClass $user)
 Deletes all instances of factor for a user.
 
 get_active_user_factors (stdClass $user)
 Grace Factor implementation.
 
 get_affecting_factors ()
 Get the factor list that is currently affecting gracemode.
 
 get_all_affecting_factors ()
 Returns a list of factor objects that can affect gracemode giving points.
 
 get_all_user_factors (stdClass $user)
 Grace Factor implementation.
 
 get_display_name ()
 Returns factor name from language string.
 
 get_icon ()
 Get the icon associated with this factor.
 
 get_info ()
 Returns factor help from language string.
 
 get_label (int $factorid)
 Function to retrieve the label for a factorid.
 
 get_lastverified (int $factorid)
 Gets lastverified timestamp.
 
 get_login_desc ()
 Get the login description associated with this factor.
 
 get_no_redirect_urls ()
 Grace factor implementation.
 
 get_remaining_attempts ()
 Return the number of remaining attempts at this factor.
 
 get_setup_string ()
 Gets the string for setup button on preferences page.
 
 get_state ($redirectable=true)
 Grace Factor implementation.
 
 get_state ()
 Returns the state of the factor from session information.
 
 get_summary_condition ()
 Returns condition for passing factor.
 
 get_weight ()
 Returns configured factor weight.
 
 global_definition (\MoodleQuickForm $mform)
 Hook point for global auth form action hooks.
 
 global_definition_after_data (\MoodleQuickForm $mform)
 Hook point for global auth form action hooks.
 
 global_submit (object $data)
 Hook point for global auth form action hooks.
 
 global_validation (array $data, array $files)
 Hook point for global auth form action hooks.
 
 has_input ()
 Grace Factor implementation.
 
 has_revoke ()
 Returns true if factor class has factor records that might be revoked.
 
 has_setup ()
 Returns true if factor needs to be setup by user and has setup_form.
 
 increment_lock_counter ()
 Increments the lock counter for a factor.
 
 is_enabled ()
 Returns true if factor is enabled, otherwise false.
 
 is_lockable ()
 Returns true if a factor is able to be locked if it fails.
 
 load_locked_state ()
 This loads the locked state from the DB Base class implementation.
 
 login_form_definition (\MoodleQuickForm $mform)
 Defines login form definition page for particular factor.
 
 login_form_definition_after_data (\MoodleQuickForm $mform)
 Defines login form definition page after form data has been set.
 
 login_form_validation (array $data)
 Implements login form validation for particular factor.
 
 possible_states (stdClass $user)
 Grace Factor implementation.
 
 post_pass_state ()
 Grace Factor implementation.
 
 process_cancel_action ()
 Process a cancel input from a user.
 
 revoke_user_factor (?int $factorid=null)
 Marks factor record as revoked.
 
 set_state (string $state)
 Grace Factor implementation.
 
 setup_factor_form_definition (\MoodleQuickForm $mform)
 Defines setup_factor form definition page for particular factor.
 
 setup_factor_form_definition_after_data (\MoodleQuickForm $mform)
 Defines setup_factor form definition page after form data has been set.
 
 setup_factor_form_validation (array $data)
 Implements setup_factor form validation for particular factor.
 
 setup_user_factor (stdClass $data)
 Setups given factor and adds it to user's active factors list.
 
 show_setup_buttons ()
 If has_setup returns true, decides if the setup buttons should be shown on the preferences page.
 
 update_lastverified (?int $factorid=null)
 When validation code is correct - update lastverified field for given factor.
 

Public Attributes

string $name
 Factor name.
 

Protected Attributes

string $icon = 'fa-lock'
 Factor icon.
 
tool_mfa local secret_manager $secretmanager
 Secret manager.
 

Member Function Documentation

◆ check_combination()

factor_grace\factor::check_combination ( array $combination)

Grace Factor implementation.

Gracemode should not be a valid combination with another factor.

Parameters
array$combinationarray of factors that make up the combination
Return values
bool

Reimplemented from tool_mfa\local\factor\object_factor_base.

◆ create_event_after_factor_setup()

tool_mfa\local\factor\object_factor_base::create_event_after_factor_setup ( object $user)
inherited

Creates an event when user successfully setup a factor.

Parameters
object$user
Return values
void

◆ delete_factor_for_user()

tool_mfa\local\factor\object_factor_base::delete_factor_for_user ( stdClass $user)
inherited

Deletes all instances of factor for a user.

Parameters
stdClass$userthe user to delete for.
Return values
void

Implements tool_mfa\local\factor\object_factor.

◆ get_active_user_factors()

factor_grace\factor::get_active_user_factors ( stdClass $user)

Grace Factor implementation.

Singleton instance, no additional filtering needed.

Parameters
stdClass$userobject to check against.
Return values
arraythe array of active factors.

Reimplemented from tool_mfa\local\factor\object_factor_base.

◆ get_affecting_factors()

factor_grace\factor::get_affecting_factors ( )

Get the factor list that is currently affecting gracemode.

Active and not ignored.

Return values
array

◆ get_all_affecting_factors()

factor_grace\factor::get_all_affecting_factors ( )

Returns a list of factor objects that can affect gracemode giving points.

Only factors that a user can setup or manually use can affect whether gracemode gives points. The intest is to provide a grace period for users to go in, setup factors, phone numbers, etc., so that they are able to authenticate correctly once the grace period ends.

Return values
array

◆ get_all_user_factors()

factor_grace\factor::get_all_user_factors ( stdClass $user)

Grace Factor implementation.

This factor is a singleton, return single instance.

Parameters
stdClass$userthe user to check against.
Return values
array

Reimplemented from tool_mfa\local\factor\object_factor_base.

◆ get_display_name()

tool_mfa\local\factor\object_factor_base::get_display_name ( )
inherited

Returns factor name from language string.

Base class implementation.

Return values
string
Exceptions
coding_exception

Implements tool_mfa\local\factor\object_factor.

Reimplemented in tool_mfa\local\factor\fallback.

◆ get_icon()

tool_mfa\local\factor\object_factor_base::get_icon ( )
inherited

Get the icon associated with this factor.

Return values
stringthe icon name.

◆ get_info()

tool_mfa\local\factor\object_factor_base::get_info ( )
inherited

Returns factor help from language string.

Base class implementation.

Return values
string
Exceptions
coding_exception

Implements tool_mfa\local\factor\object_factor.

Reimplemented in tool_mfa\local\factor\fallback.

◆ get_label()

tool_mfa\local\factor\object_factor_base::get_label ( int $factorid)
inherited

Function to retrieve the label for a factorid.

Parameters
int$factorid
Return values
string|dml_exception

Implements tool_mfa\local\factor\object_factor.

◆ get_lastverified()

tool_mfa\local\factor\object_factor_base::get_lastverified ( int $factorid)
inherited

Gets lastverified timestamp.

Parameters
int$factorid
Return values
int|boolthe lastverified timestamp, or false if not found.

Implements tool_mfa\local\factor\object_factor.

◆ get_login_desc()

tool_mfa\local\factor\object_factor_base::get_login_desc ( )
inherited

Get the login description associated with this factor.

Override for factors that have a user input.

Return values
stringThe login option.

Reimplemented in factor_email\factor.

◆ get_no_redirect_urls()

factor_grace\factor::get_no_redirect_urls ( )

Grace factor implementation.

If grace period should redirect at end, make this a no-redirect url.

Return values
array

Reimplemented from tool_mfa\local\factor\object_factor_base.

◆ get_remaining_attempts()

tool_mfa\local\factor\object_factor_base::get_remaining_attempts ( )
inherited

Return the number of remaining attempts at this factor.

Return values
intthe number of attempts at this factor remaining.

◆ get_setup_string()

tool_mfa\local\factor\object_factor_base::get_setup_string ( )
inherited

Gets the string for setup button on preferences page.

Return values
string

Implements tool_mfa\local\factor\object_factor.

Reimplemented in factor_totp\factor, and factor_webauthn\factor.

◆ get_state() [1/2]

factor_grace\factor::get_state ( $redirectable = true)

Grace Factor implementation.

Checks the user login time against their first login after MFA activation.

Parameters
bool$redirectableshould this state call be allowed to redirect the user?
Return values
stringstate constant

◆ get_state() [2/2]

tool_mfa\local\factor\object_factor_base::get_state ( )
inherited

Returns the state of the factor from session information.

Implementation for factors that require input. Should be overridden in child classes with no input.

Return values
mixed

Implements tool_mfa\local\factor\object_factor.

Reimplemented in factor_admin\factor, factor_auth\factor, factor_capability\factor, factor_cohort\factor, factor_email\factor, factor_iprange\factor, factor_nosetup\factor, factor_role\factor, factor_token\factor, factor_totp\factor, factor_webauthn\factor, and tool_mfa\local\factor\fallback.

◆ get_summary_condition()

tool_mfa\local\factor\object_factor_base::get_summary_condition ( )
inherited

Returns condition for passing factor.

Implementation for basic conditions. Override for complex conditions such as auth type.

Return values
string

Implements tool_mfa\local\factor\object_factor.

Reimplemented in factor_auth\factor, factor_cohort\factor, and factor_role\factor.

◆ get_weight()

tool_mfa\local\factor\object_factor_base::get_weight ( )
inherited

Returns configured factor weight.

Base class implementation.

Return values
int
Exceptions
dml_exception

Implements tool_mfa\local\factor\object_factor.

◆ global_definition()

tool_mfa\local\factor\object_factor_base::global_definition ( \MoodleQuickForm $mform)
inherited

Hook point for global auth form action hooks.

Parameters
MoodleQuickForm$mformForm to inject global elements into.
Return values
void

Implements tool_mfa\local\factor\object_factor.

◆ global_definition_after_data()

tool_mfa\local\factor\object_factor_base::global_definition_after_data ( \MoodleQuickForm $mform)
inherited

Hook point for global auth form action hooks.

Parameters
MoodleQuickForm$mformForm to inject global elements into.
Return values
void

Implements tool_mfa\local\factor\object_factor.

◆ global_submit()

tool_mfa\local\factor\object_factor_base::global_submit ( object $data)
inherited

Hook point for global auth form action hooks.

Parameters
object$dataData from the form.
Return values
void

Implements tool_mfa\local\factor\object_factor.

◆ global_validation()

tool_mfa\local\factor\object_factor_base::global_validation ( array $data,
array $files )
inherited

Hook point for global auth form action hooks.

Parameters
array$dataData from the form.
array$filesFiles form the form.
Return values
arrayof errors from validation.

Implements tool_mfa\local\factor\object_factor.

◆ has_input()

factor_grace\factor::has_input ( )

Grace Factor implementation.

Factor has no input.

Returns true if a factor requires input from the user to verify.Override in child class if necessary

Return values
bool

Reimplemented from tool_mfa\local\factor\object_factor_base.

◆ has_revoke()

tool_mfa\local\factor\object_factor_base::has_revoke ( )
inherited

Returns true if factor class has factor records that might be revoked.

It means that user can revoke factor record from their profile.

Override in child class if necessary.

Return values
bool

Implements tool_mfa\local\factor\object_factor.

Reimplemented in factor_totp\factor, and factor_webauthn\factor.

◆ has_setup()

tool_mfa\local\factor\object_factor_base::has_setup ( )
inherited

Returns true if factor needs to be setup by user and has setup_form.

Override in child class if necessary.

Return values
bool

Implements tool_mfa\local\factor\object_factor.

Reimplemented in factor_totp\factor, and factor_webauthn\factor.

◆ increment_lock_counter()

tool_mfa\local\factor\object_factor_base::increment_lock_counter ( )
inherited

Increments the lock counter for a factor.

Return values
void

◆ is_enabled()

tool_mfa\local\factor\object_factor_base::is_enabled ( )
inherited

Returns true if factor is enabled, otherwise false.

Base class implementation.

Return values
bool
Exceptions
dml_exception

Implements tool_mfa\local\factor\object_factor.

◆ is_lockable()

tool_mfa\local\factor\object_factor_base::is_lockable ( )
inherited

Returns true if a factor is able to be locked if it fails.

Generally only input factors are lockable. Override in child class if necessary

Return values
bool

◆ load_locked_state()

tool_mfa\local\factor\object_factor_base::load_locked_state ( )
inherited

This loads the locked state from the DB Base class implementation.

Return values
void

◆ login_form_definition()

tool_mfa\local\factor\object_factor_base::login_form_definition ( \MoodleQuickForm $mform)
inherited

Defines login form definition page for particular factor.

Dummy implementation. Should be overridden in child class.

Parameters
MoodleQuickForm$mform
Return values
object\$mform

Implements tool_mfa\local\factor\object_factor.

Reimplemented in factor_email\factor, factor_totp\factor, and factor_webauthn\factor.

◆ login_form_definition_after_data()

tool_mfa\local\factor\object_factor_base::login_form_definition_after_data ( \MoodleQuickForm $mform)
inherited

Defines login form definition page after form data has been set.

Dummy implementation. Should be overridden in child class.

Parameters
MoodleQuickForm$mform
Return values
object\$mform

Implements tool_mfa\local\factor\object_factor.

Reimplemented in factor_email\factor.

◆ login_form_validation()

tool_mfa\local\factor\object_factor_base::login_form_validation ( array $data)
inherited

Implements login form validation for particular factor.

Returns an array of errors, where array key = field id and array value = error text.

Dummy implementation. Should be overridden in child class.

Parameters
array$data
Return values
array

Implements tool_mfa\local\factor\object_factor.

Reimplemented in factor_email\factor, factor_totp\factor, and factor_webauthn\factor.

◆ possible_states()

factor_grace\factor::possible_states ( stdClass $user)

Grace Factor implementation.

Gracemode can change outcome just by waiting, or based on other factors.

Parameters
stdClass$user
Return values
array

Reimplemented from tool_mfa\local\factor\object_factor_base.

◆ post_pass_state()

factor_grace\factor::post_pass_state ( )

Grace Factor implementation.

Add a notification on the next page.

Function for factor actions in the pass state.Override in child class if necessary.

Return values
void

Reimplemented from tool_mfa\local\factor\object_factor_base.

◆ process_cancel_action()

tool_mfa\local\factor\object_factor_base::process_cancel_action ( )
inherited

Process a cancel input from a user.

Return values
void

Implements tool_mfa\local\factor\object_factor.

◆ revoke_user_factor()

tool_mfa\local\factor\object_factor_base::revoke_user_factor ( ?int $factorid = null)
inherited

Marks factor record as revoked.

If factorid is not provided, revoke all instances of factor.

Parameters
int | null$factorid
Return values
bool
Exceptions
coding_exception
dml_exception

Implements tool_mfa\local\factor\object_factor.

◆ set_state()

factor_grace\factor::set_state ( string $state)

Grace Factor implementation.

State cannot be set. Return true.

Parameters
string$statethe state constant to set
Return values
bool

Reimplemented from tool_mfa\local\factor\object_factor_base.

◆ setup_factor_form_definition()

tool_mfa\local\factor\object_factor_base::setup_factor_form_definition ( \MoodleQuickForm $mform)
inherited

Defines setup_factor form definition page for particular factor.

Dummy implementation. Should be overridden in child class.

Parameters
MoodleQuickForm$mform
Return values
object\$mform

Implements tool_mfa\local\factor\object_factor.

Reimplemented in factor_totp\factor, and factor_webauthn\factor.

◆ setup_factor_form_definition_after_data()

tool_mfa\local\factor\object_factor_base::setup_factor_form_definition_after_data ( \MoodleQuickForm $mform)
inherited

Defines setup_factor form definition page after form data has been set.

Dummy implementation. Should be overridden in child class.

Parameters
MoodleQuickForm$mform
Return values
object\$mform

Implements tool_mfa\local\factor\object_factor.

Reimplemented in factor_totp\factor.

◆ setup_factor_form_validation()

tool_mfa\local\factor\object_factor_base::setup_factor_form_validation ( array $data)
inherited

Implements setup_factor form validation for particular factor.

Returns an array of errors, where array key = field id and array value = error text.

Dummy implementation. Should be overridden in child class.

Parameters
array$data
Return values
array

Implements tool_mfa\local\factor\object_factor.

Reimplemented in factor_totp\factor.

◆ setup_user_factor()

tool_mfa\local\factor\object_factor_base::setup_user_factor ( stdClass $data)
inherited

Setups given factor and adds it to user's active factors list.

Returns true if factor has been successfully added, otherwise false.

Dummy implementation. Should be overridden in child class.

Parameters
stdClass$data
Return values
stdClass|nullthe record if created, or null.

Implements tool_mfa\local\factor\object_factor.

Reimplemented in factor_totp\factor.

◆ show_setup_buttons()

tool_mfa\local\factor\object_factor_base::show_setup_buttons ( )
inherited

If has_setup returns true, decides if the setup buttons should be shown on the preferences page.

Return values
bool

Implements tool_mfa\local\factor\object_factor.

Reimplemented in factor_totp\factor, and factor_webauthn\factor.

◆ update_lastverified()

tool_mfa\local\factor\object_factor_base::update_lastverified ( ?int $factorid = null)
inherited

When validation code is correct - update lastverified field for given factor.

If factor id is not provided, update all factor entries for user.

Parameters
int | null$factorid
Return values
bool|dml_exception
Exceptions
dml_exception

Implements tool_mfa\local\factor\object_factor.


The documentation for this class was generated from the following file: