Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 1.02 KB

creating-mfa-method-backend.md

File metadata and controls

28 lines (21 loc) · 1.02 KB

Creating a new MFA method: Backend

Method availability

If your method isn't available in some situations, and you can determine this via server-side state, you can provide this information to the frontend via MethodInterface::isAvailable(), for example:

class MyMethod implements MethodInterface
{
    public function isAvailable(): bool
    {
        return Injector::inst()->get(HTTPRequest::class)->getHeader('something') === 'example';
    }

    public function getUnavailableMessage(): string
    {
        return 'My silly example criteria was not fulfilled, so you cannot use me.';
    }
}

The results of both of these methods are automatically exposed to the MFA application schema when the registration / verification UI is loaded, so no extra work is required to incorporate them.

If you need to determine the availability of your method via the frontend, see Creating a new MFA method: Frontend