Tfa class
Tfa - ProcessWire Two Factor Authentication module base class
This class is for “Tfa” modules to extend. See the TfaEmail and TfaTotp modules as examples.
USAGE
$tfa = new Tfa();
if($tfa->success()) {
$session->redirect('after/login/url/');
} else if($tfa->active()) {
echo $tfa->render();
} else if($input->post('submit_login')) {
$name = $input->post('name');
$pass = $input->post('pass');
$tfa->start($name, $pass);
the start() method performs a redirect if TFA is active for the user
place your regular code to login user here, which will be used if TFA is not active for the user
} else {
render login form
}
SETTINGS
TEXT LABELS
HOOKABLE METHODS
There are 2 Tfa types in the core, plus many more Tfa modules in our directory.
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Tfa
class also inherits all the methods and properties of: WireData and Wire.
Common
Properties
Name | Return | Summary | Default |
---|---|---|---|
Tfa::autoRoleIDs | array | Role IDs to enforce $autoType or blank for all roles, applies only if $autoType set | [] |
Tfa::autoType | string | Automatic/force TFA type (module name) to use when user doesn’t already have TFA enabled | '' |
Tfa::cancelLabel | string | Label to use for Cancel link | 'Cancel', translatable |
Tfa::cancelMarkup | string | Markup to use for the cancel link that appears under auth code form, must have {url} and {label} placeholders. | |
Tfa::codeExpire | int | Codes expire after this many seconds | 180 |
Tfa::codeLength | int | Required length for authentication code | 6 |
Tfa::codeType | int | Type of TFA code to use, see codeType constants | 0, which is Tfa::codeTypeDigits |
Tfa::configureLabel | string | Indicates that TFA needs to be configured | |
Tfa::enabledDescLabel | string | Describes enabled TFA and how to change settings | |
Tfa::enabledLabel | string | Indicates TFA enabled | |
Tfa::expiredCodeLabel | string | Expired code error | |
Tfa::fieldTfaTypeDescLabel | string | Description of 2-factor auth type | |
Tfa::fieldTfaTypeLabel | string | Select 2-factor auth type | |
Tfa::formAttrs | array | Form <form> element attributes | |
Tfa::inputAttrs | array | Code <input> element attributes | |
Tfa::inputLabel | string | Label for code <input> element | |
Tfa::invalidCodeLabel | string | Invalid code error | |
Tfa::maxAttemptsLabel | string | Max attempts error | |
Tfa::rememberClearLabel | string | Clear remembered browsers | |
Tfa::rememberClearedLabel | string | Message after remembered browsers cleared | |
Tfa::rememberDays | int | Number of days to "remember this browser", 0 to disable option, or -1 for no limit? | 0 |
Tfa::rememberFingerprints | array | Fingerprints to remember: agent,agentVL,accept,scheme,host,ip,fwip | agentVL,accept,scheme,host |
Tfa::rememberLabel | string | Label for "remember this browser" option | |
Tfa::rememberSkipLabel | string | Indicates that code entry was skipped because browser is remembered | |
Tfa::rememberSuccessLabel | string | Indicates that browser has been saved/remembered for n days. | |
Tfa::sendCodeErrorLabel | string | Error creating or sending code | |
Tfa::showCancel | bool | Show a cancel link under authentication code form? | true |
Tfa::startUrl | string | URL we are operating from | './' |
Tfa::submitAttrs | array | Submit button attributes | |
Tfa::submitLabel | string | Label for submit button | |
Tfa::timeLimitLabel | string | Time limit reached error |
Additional methods and properties
In addition to the methods and properties above, Tfa also inherits the methods and properties of these classes:
Core Tfa types
See also: Tfa modules in the modules directory
API reference based on ProcessWire core version 3.0.251