Skip to main content


Managing 2FA app passwords results in "Uncaught Exception TypeError"


Hi @Friendica Support
Next bug I found (I think ;)):
When 2FA is enabled and I'm trying to add a new app password (on settings/2fa/app_specific)the process fails with a blank page (where normally the new app password is displayed) and the following error:
Uncaught Exception TypeError: "Argument 1 passed to Friendica\Util\Temporal::getRelativeDate() must be of the type string, null given, called in src/Security/TwoFactor/Model/AppSpecificPassword.php on line 89" at src/Util/Temporal.php line 314
In addition the 2FA page with the active app passwords now fails completely (white page) until the 2fa_app_specific_password table is edited manually by removing the entries with empty last_used field - filling the field should work, too.

It seems the problem is the field last_used in the database table 2fa_app_specific_password. When creating a new app password this field is initially blank. This seems to be a problem for the function getListForUser($uid) in src/Security/TwoFactor/Model/AppSpecificPassword.php since when I comment out the follwing lines everything is working again:
$value['ago'] = Temporal::getRelativeDate($value['last_used']);
$value['utc'] = $value['last_used'] ? DateTimeFormat::utc($value['last_used'], 'c') : '';
$value['local'] = $value['last_used'] ? DateTimeFormat::local($value['last_used'], 'r') : '';

Friendica version is 2022.10.

Friendica Support reshared this.

Thank you for the report!

Friendica Support reshared this.

I just checked, this error has been fixed on October 18th in the develop branch, here's the diff if you don't want to check out the whole branch on your node: https://github.com/friendica/friendica/pull/11996/files

Friendica Support reshared this.

@Hypolite Petovan Thank you! I'll wait for the update then! :)

Friendica Support reshared this.

Can confirm: fixed in 2022.12-dev 👍

Friendica Support reshared this.