Skip to content

Commit

Permalink
php codesniffer fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kbwhizz committed Nov 1, 2024
1 parent ecbcf29 commit 55fb9e2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
1 change: 0 additions & 1 deletion app/Http/RequestHandlers/AccountUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
if ($secret !== '' || $status_mfa === false) {
$user->setSecret($secret);
}

// Change the username
if ($user_name !== $user->userName()) {
if ($this->user_service->findByUserName($user_name) === null) {
Expand Down
7 changes: 3 additions & 4 deletions app/Http/RequestHandlers/LoginAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,14 @@ private function doLogin(string $username, #[\SensitiveParameter] string $passwo
}
if ($user->getPreference(UserInterface::PREF_IS_STATUS_MFA) !== '') {
# covers scenario where 2fa not enabled by user
if($code2fa != '') {
if ($code2fa != '') {
if (!$user->check2FAcode($code2fa)) {
throw new Exception(I18N::translate('2FA code does not match. Please try again.'));
}
}
else {
} else {
throw new Exception(I18N::translate('2FA code must be entered as you have 2FA authentication enabled. Please try again.'));
}
}
}
Auth::login($user);
Log::addAuthenticationLog('Login: ' . Auth::user()->userName() . '/' . Auth::user()->realName());
Auth::user()->setPreference(UserInterface::PREF_TIMESTAMP_ACTIVE, (string) time());
Expand Down
6 changes: 3 additions & 3 deletions app/Http/RequestHandlers/RegisterAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ private function doValidateRegistration(
ServerRequestInterface $request,
string $username,
string $email,
string $realname,
string $realname,
string $comments,
#[\SensitiveParameter] string $password,
string $secret
#[\SensitiveParameter] string $password,
string $secret
): void {
// All fields are required
if ($username === '' || $email === '' || $realname === '' || $comments === '' || $password === '') {
Expand Down
9 changes: 5 additions & 4 deletions app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ public function genQRcode(): array
$google2fa = new Google2FA();
$qrinfo['secret'] = $google2fa->generateSecretKey();
$data = 'otpauth://totp/' . $this->user_id . '?secret=' . $qrinfo['secret'] . '&issuer=' . $_SERVER['SERVER_NAME'];
$qrinfo['qrcode'] = (new QRCode)->render($data);
$qrinfo['qrcode'] = new QRCode();
$qrinfo['qrcode'] = QRCode->render($data);
return $qrinfo;
}

/**
* Set the real name of this user.
*
Expand Down Expand Up @@ -290,8 +291,8 @@ public function check2facode(string $code2fa): bool
$secret = DB::table('user')
->where('user_id', '=', $this->id())
->value('secret');
$google2fa = new Google2FA;
if($google2fa->verifyKey($secret, $code2fa)) {
$google2fa = new Google2FA();
if ($google2fa->verifyKey($secret, $code2fa)) {
return true;
}
return false;
Expand Down
4 changes: 2 additions & 2 deletions tests/app/Http/RequestHandlers/AccountUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public function testHandler(): void
'timezone' => 'g',
'user_name' => 'h',
'visible-online' => 'i',
'secret' => 'j',
'status-mfa' => 'k',
'secret' => 'j',
'status-mfa' => 'k',
]);
$response = $handler->handle($request);

Expand Down

0 comments on commit 55fb9e2

Please sign in to comment.