class UserMfa (View source)

Constants

TYPE_APP

TYPE_EMAIL

Methods

__construct(int $id, int $userId, bool $enabled, string|null $secret, string|null $recoveryCodes, string $type, DateTime|null $lastUsedAt, DateTime $createdAt, DateTime|null $updatedAt, string|null $verificationData = null)

No description

static UserMfa
create(int $userId, bool $enabled = false, string|null $secret = null, string|null $recoveryCodes = null, string $type = self::TYPE_APP, string|null $verificationData = null)

No description

int
getId()

No description

int
getUserId()

No description

bool
isEnabled()

No description

void
enable()

No description

void
disable()

No description

string|null
getSecret()

No description

void
setSecret(string|null $secret)

No description

string|null
getRecoveryCodes()

No description

array
getRecoveryCodesAsArray()

No description

void
setRecoveryCodes(array $recoveryCodes)

No description

void
setVerificationMetadata(array $metadata)

Store verification metadata for email-based MFA

void
setRecoveryCodesRaw(string $jsonString)

Set raw JSON string for recovery codes (for backward compatibility)

string|null
getVerificationData()

Get verification data

array
getVerificationDataAsArray()

Get verification data as array

void
setVerificationData(array $data)

Set verification data

void
setVerificationDataRaw(string $jsonString)

Set raw verification data (JSON string)

string
getType()

No description

void
setType(string $type)

No description

MfaFactorType|null
getFactorType()

The configured factor as an enum, or null for a type this build no longer knows.

DateTime|null
getLastUsedAt()

No description

void
updateLastUsed()

No description

getCreatedAt()

No description

DateTime|null
getUpdatedAt()

No description

bool
validateRecoveryCode(string $code)

Check if a recovery code is valid and remove it from the list if it is

array
generateRecoveryCodes(int $count = 10, int $length = 10)

Generate new recovery codes

Details

__construct(int $id, int $userId, bool $enabled, string|null $secret, string|null $recoveryCodes, string $type, DateTime|null $lastUsedAt, DateTime $createdAt, DateTime|null $updatedAt, string|null $verificationData = null)

No description

Parameters

int $id
int $userId
bool $enabled
string|null $secret
string|null $recoveryCodes
string $type
DateTime|null $lastUsedAt
DateTime $createdAt
DateTime|null $updatedAt
string|null $verificationData

static UserMfa create(int $userId, bool $enabled = false, string|null $secret = null, string|null $recoveryCodes = null, string $type = self::TYPE_APP, string|null $verificationData = null)

No description

Parameters

int $userId
bool $enabled
string|null $secret
string|null $recoveryCodes
string $type
string|null $verificationData

Return Value

UserMfa

int getId()

No description

Return Value

int

int getUserId()

No description

Return Value

int

bool isEnabled()

No description

Return Value

bool

void enable()

No description

Return Value

void

void disable()

No description

Return Value

void

string|null getSecret()

No description

Return Value

string|null

void setSecret(string|null $secret)

No description

Parameters

string|null $secret

Return Value

void

string|null getRecoveryCodes()

No description

Return Value

string|null

array getRecoveryCodesAsArray()

No description

Return Value

array

void setRecoveryCodes(array $recoveryCodes)

No description

Parameters

array $recoveryCodes

Return Value

void

void setVerificationMetadata(array $metadata)

Store verification metadata for email-based MFA

Parameters

array $metadata

The verification metadata

Return Value

void

void setRecoveryCodesRaw(string $jsonString)

Set raw JSON string for recovery codes (for backward compatibility)

Parameters

string $jsonString

JSON string to set

Return Value

void

string|null getVerificationData()

Get verification data

Return Value

string|null

The verification data

array getVerificationDataAsArray()

Get verification data as array

Return Value

array

The verification data as array

void setVerificationData(array $data)

Set verification data

Parameters

array $data

The verification data to set

Return Value

void

void setVerificationDataRaw(string $jsonString)

Set raw verification data (JSON string)

Parameters

string $jsonString

The verification data as JSON string

Return Value

void

string getType()

No description

Return Value

string

void setType(string $type)

No description

Parameters

string $type

Return Value

void

MfaFactorType|null getFactorType()

The configured factor as an enum, or null for a type this build no longer knows.

Return Value

MfaFactorType|null

DateTime|null getLastUsedAt()

No description

Return Value

DateTime|null

void updateLastUsed()

No description

Return Value

void

DateTime getCreatedAt()

No description

Return Value

DateTime

DateTime|null getUpdatedAt()

No description

Return Value

DateTime|null

bool validateRecoveryCode(string $code)

Check if a recovery code is valid and remove it from the list if it is

Parameters

string $code

The recovery code to validate

Return Value

bool

True if the code is valid, false otherwise

array generateRecoveryCodes(int $count = 10, int $length = 10)

Generate new recovery codes

Parameters

int $count

Number of recovery codes to generate

int $length

Length of each recovery code in bytes (before hex encoding)

Return Value

array

The generated recovery codes