From e3730cc755effbfaa3ffafec6a621a91d7a50fc8 Mon Sep 17 00:00:00 2001 From: briskt <3172830+briskt@users.noreply.github.com> Date: Fri, 24 May 2024 17:16:19 +0800 Subject: [PATCH] fix exception thrown when a user is low on printable codes This error was shown in the browser: ``` SimpleSAML\Error\Error: UNHANDLEDEXCEPTION Backtrace: 1 www/_include.php:20 (SimpleSAML_exception_handler) 0 [builtin] (N/A) Caused by: TypeError: str_replace(): Argument #2 ($replace) must be of type array|string, int given Backtrace: 7 lib/SimpleSAML/Locale/Translate.php:308 (str_replace) 6 lib/SimpleSAML/Locale/Translate.php:308 (SimpleSAML\Locale\Translate::t) 5 lib/SimpleSAML/XHTML/Template.php:914 (SimpleSAML\XHTML\Template::t) 4 modules/material/themes/material/mfa/low-on-backup-codes.php:32 (require) 3 lib/SimpleSAML/XHTML/Template.php:560 (SimpleSAML\XHTML\Template::show) 2 modules/mfa/www/low-on-backup-codes.php:35 (require) 1 lib/SimpleSAML/Module.php:266 (SimpleSAML\Module::process) 0 www/module.php:10 (N/A) ``` --- modules/mfa/lib/Auth/Process/Mfa.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/mfa/lib/Auth/Process/Mfa.php b/modules/mfa/lib/Auth/Process/Mfa.php index ecf95aa8..44b475eb 100644 --- a/modules/mfa/lib/Auth/Process/Mfa.php +++ b/modules/mfa/lib/Auth/Process/Mfa.php @@ -761,7 +761,7 @@ protected static function redirectToLowOnBackupCodesNag( $numBackupCodesRemaining ) { $state['employeeId'] = $employeeId; - $state['numBackupCodesRemaining'] = $numBackupCodesRemaining; + $state['numBackupCodesRemaining'] = (string)$numBackupCodesRemaining; $stateId = State::saveState($state, self::STAGE_SENT_TO_LOW_ON_BACKUP_CODES_NAG); $url = Module::getModuleURL('mfa/low-on-backup-codes.php');