From abee9ab85449c12bc85692614644d01c13b1ce09 Mon Sep 17 00:00:00 2001 From: Bernard Date: Mon, 25 Nov 2024 15:42:50 +0000 Subject: [PATCH] Fix mixed typing on 126 and 296 by forcing to string or bool --- app/User.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/User.php b/app/User.php index 4c97cd869a..89882c08ab 100644 --- a/app/User.php +++ b/app/User.php @@ -123,7 +123,9 @@ public function genQRcode(): array $qrinfo = array(); $google2fa = new Google2FA(); $qrinfo['secret'] = $google2fa->generateSecretKey(); - $data = 'otpauth://totp/' . $this->user_id . '?secret=' . $qrinfo['secret'] . '&issuer=' . $_SERVER['SERVER_NAME']; + $servername = $_SERVER['SERVER_NAME']; + settype($servername, "string"); + $data = 'otpauth://totp/' . $this->user_id . '?secret=' . $qrinfo['secret'] . '&issuer=' . $servername; $qrcode = new QRCode(); $qrinfo['qrcode'] = $qrcode->render($data); return $qrinfo; @@ -291,8 +293,11 @@ public function check2facode(string $code2fa): bool $secret = DB::table('user') ->where('user_id', '=', $this->id()) ->value('secret'); + settype($secret, "string"); $google2fa = new Google2FA(); - if ($google2fa->verifyKey($secret, $code2fa)) { + $googleverifystatus = $google2fa->verifyKey($secret, $code2fa); + settype($googleverifystatus, "bool"); + if ($googleverifystatus) { return true; } return false;