Fix pint issues

This commit is contained in:
Bubka 2024-04-26 08:01:20 +02:00
parent c6f8317d81
commit 7e1fdf67bb
18 changed files with 75 additions and 86 deletions

View File

@ -61,7 +61,7 @@ public function toArray($request)
'platform' => $this->agent->platform(), 'platform' => $this->agent->platform(),
'device' => $this->agent->deviceType(), 'device' => $this->agent->deviceType(),
'login_at' => $this->login_at 'login_at' => $this->login_at
? Carbon::parse($this->login_at,)->tz($tz)->toDayDateTimeString() ? Carbon::parse($this->login_at)->tz($tz)->toDayDateTimeString()
: null, : null,
'logout_at' => $this->logout_at 'logout_at' => $this->logout_at
? Carbon::parse($this->logout_at)->tz($tz)->toDayDateTimeString() ? Carbon::parse($this->logout_at)->tz($tz)->toDayDateTimeString()

View File

@ -31,8 +31,6 @@ class FailedLoginListener extends AbstractAccessListener
{ {
/** /**
* Handle the event. * Handle the event.
*
* @return void
*/ */
public function handle(mixed $event) : void public function handle(mixed $event) : void
{ {

View File

@ -32,8 +32,6 @@ class LoginListener extends AbstractAccessListener
{ {
/** /**
* Handle the event. * Handle the event.
*
* @return void
*/ */
public function handle(mixed $event) : void public function handle(mixed $event) : void
{ {

View File

@ -31,8 +31,6 @@ class LogoutListener extends AbstractAccessListener
{ {
/** /**
* Handle the event. * Handle the event.
*
* @return void
*/ */
public function handle(mixed $event) : void public function handle(mixed $event) : void
{ {

View File

@ -31,8 +31,6 @@ class OtherDeviceLogoutListener extends AbstractAccessListener
{ {
/** /**
* Handle the event. * Handle the event.
*
* @return void
*/ */
public function handle(mixed $event) : void public function handle(mixed $event) : void
{ {

View File

@ -4,7 +4,6 @@
use App\Events\VisitedByProxyUser; use App\Events\VisitedByProxyUser;
use App\Extensions\RemoteUserProvider; use App\Extensions\RemoteUserProvider;
use App\Listeners\Authentication\AbstractAccessListener;
use App\Notifications\SignedInWithNewDevice; use App\Notifications\SignedInWithNewDevice;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
@ -12,10 +11,8 @@ class VisitedByProxyUserListener extends AbstractAccessListener
{ {
/** /**
* Handle the event. * Handle the event.
*
* @return void
*/ */
public function handle(mixed $event): void public function handle(mixed $event) : void
{ {
if (! $event instanceof VisitedByProxyUser) { if (! $event instanceof VisitedByProxyUser) {
return; return;

View File

@ -2,8 +2,8 @@
namespace App\Models; namespace App\Models;
use App\Models\Traits\WebAuthnManageCredentials;
use App\Models\Traits\HasAuthenticationLog; use App\Models\Traits\HasAuthenticationLog;
use App\Models\Traits\WebAuthnManageCredentials;
use Illuminate\Auth\Events\PasswordReset; use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Auth\Notifications\ResetPassword; use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Contracts\Translation\HasLocalePreference; use Illuminate\Contracts\Translation\HasLocalePreference;
@ -53,8 +53,8 @@
*/ */
class User extends Authenticatable implements HasLocalePreference, WebAuthnAuthenticatable class User extends Authenticatable implements HasLocalePreference, WebAuthnAuthenticatable
{ {
use HasAuthenticationLog;
use HasApiTokens, HasFactory, Notifiable; use HasApiTokens, HasFactory, Notifiable;
use HasAuthenticationLog;
use WebAuthnAuthentication, WebAuthnManageCredentials; use WebAuthnAuthentication, WebAuthnManageCredentials;
/** /**

View File

@ -2,15 +2,15 @@
namespace App\Providers; namespace App\Providers;
use App\Listeners\Authentication\VisitedByProxyUserListener;
use App\Events\GroupDeleted; use App\Events\GroupDeleted;
use App\Events\GroupDeleting; use App\Events\GroupDeleting;
use App\Events\VisitedByProxyUser;
use App\Events\ScanForNewReleaseCalled; use App\Events\ScanForNewReleaseCalled;
use App\Events\TwoFAccountDeleted; use App\Events\TwoFAccountDeleted;
use App\Events\VisitedByProxyUser;
use App\Listeners\Authentication\FailedLoginListener; use App\Listeners\Authentication\FailedLoginListener;
use App\Listeners\Authentication\LoginListener; use App\Listeners\Authentication\LoginListener;
use App\Listeners\Authentication\LogoutListener; use App\Listeners\Authentication\LogoutListener;
use App\Listeners\Authentication\VisitedByProxyUserListener;
use App\Listeners\CleanIconStorage; use App\Listeners\CleanIconStorage;
use App\Listeners\DissociateTwofaccountFromGroup; use App\Listeners\DissociateTwofaccountFromGroup;
use App\Listeners\LogNotification; use App\Listeners\LogNotification;

View File

@ -58,14 +58,17 @@ protected function getUserByToken($token)
*/ */
public function refreshToken($refreshToken) public function refreshToken($refreshToken)
{ {
return $this->getHttpClient()->post($this->getTokenUrl(), [/** @phpstan-ignore-line */ return $this->getHttpClient()->post( /** @phpstan-ignore-line */
$this->getTokenUrl(),
[
RequestOptions::FORM_PARAMS => [ RequestOptions::FORM_PARAMS => [
'client_id' => $this->clientId, 'client_id' => $this->clientId,
'client_secret' => $this->clientSecret, 'client_secret' => $this->clientSecret,
'grant_type' => 'refresh_token', 'grant_type' => 'refresh_token',
'refresh_token' => $refreshToken, 'refresh_token' => $refreshToken,
], ],
]); ]
);
} }
/** /**

View File

@ -94,9 +94,9 @@ public function test_allPreferences_returns_preferences_with_user_values()
foreach (config('2fauth.preferences') as $pref => $value) { foreach (config('2fauth.preferences') as $pref => $value) {
if (is_numeric($value)) { if (is_numeric($value)) {
$userPrefs[$pref] = $value + 1; $userPrefs[$pref] = $value + 1;
} else if (is_string($value)) { } elseif (is_string($value)) {
$userPrefs[$pref] = $value . '_'; $userPrefs[$pref] = $value . '_';
} else if (is_bool($value)) { } elseif (is_bool($value)) {
$userPrefs[$pref] = ! $value; $userPrefs[$pref] = ! $value;
} }

View File

@ -96,36 +96,36 @@ public function test_index_returns_all_users_with_expected_UserManagerResources(
->assertJsonCount(3) ->assertJsonCount(3)
->assertJsonStructure([ ->assertJsonStructure([
'*' => [ '*' => [
"last_seen_at", 'last_seen_at',
"created_at", 'created_at',
] ],
]) ])
->assertJsonFragment([ ->assertJsonFragment([
"id" => $this->user->id, 'id' => $this->user->id,
"name" => $this->user->name, 'name' => $this->user->name,
"email" => $this->user->email, 'email' => $this->user->email,
"oauth_provider" => null, 'oauth_provider' => null,
"preferences" => $this->defaultPreferences, 'preferences' => $this->defaultPreferences,
"is_admin" => false, 'is_admin' => false,
"twofaccounts_count" => 0, 'twofaccounts_count' => 0,
]) ])
->assertJsonFragment([ ->assertJsonFragment([
"id" => $this->admin->id, 'id' => $this->admin->id,
"name" => $this->admin->name, 'name' => $this->admin->name,
"email" => $this->admin->email, 'email' => $this->admin->email,
"oauth_provider" => null, 'oauth_provider' => null,
"preferences" => $this->defaultPreferences, 'preferences' => $this->defaultPreferences,
"is_admin" => true, 'is_admin' => true,
"twofaccounts_count" => 0, 'twofaccounts_count' => 0,
]) ])
->assertJsonFragment([ ->assertJsonFragment([
"id" => $this->anotherUser->id, 'id' => $this->anotherUser->id,
"name" => $this->anotherUser->name, 'name' => $this->anotherUser->name,
"email" => $this->anotherUser->email, 'email' => $this->anotherUser->email,
"oauth_provider" => null, 'oauth_provider' => null,
"preferences" => $this->defaultPreferences, 'preferences' => $this->defaultPreferences,
"is_admin" => false, 'is_admin' => false,
"twofaccounts_count" => 1, 'twofaccounts_count' => 1,
]); ]);
} }
@ -137,20 +137,20 @@ public function test_show_returns_the_expected_UserManagerResource() : void
$this->actingAs($this->admin, 'api-guard') $this->actingAs($this->admin, 'api-guard')
->json('GET', '/api/v1/users/' . $this->user->id) ->json('GET', '/api/v1/users/' . $this->user->id)
->assertJson([ ->assertJson([
"info" => [ 'info' => [
"id" => $this->user->id, 'id' => $this->user->id,
"name" => $this->user->name, 'name' => $this->user->name,
"email" => $this->user->email, 'email' => $this->user->email,
"oauth_provider" => null, 'oauth_provider' => null,
"preferences" => $this->defaultPreferences, 'preferences' => $this->defaultPreferences,
"is_admin" => false, 'is_admin' => false,
"twofaccounts_count" => 0, 'twofaccounts_count' => 0,
"last_seen_at" => "1 second ago", 'last_seen_at' => '1 second ago',
"created_at" => "1 second ago" 'created_at' => '1 second ago',
], ],
"password_reset" => null, 'password_reset' => null,
"valid_personal_access_tokens" => 0, 'valid_personal_access_tokens' => 0,
"webauthn_credentials" => 0 'webauthn_credentials' => 0,
]); ]);
} }

View File

@ -98,7 +98,7 @@ public function test_login_send_new_device_notification()
'email' => $this->user->email, 'email' => $this->user->email,
'password' => self::PASSWORD, 'password' => self::PASSWORD,
], [ ], [
'HTTP_USER_AGENT' => 'NotSymfony' 'HTTP_USER_AGENT' => 'NotSymfony',
])->assertOk(); ])->assertOk();
Notification::assertSentTo($this->user, SignedInWithNewDevice::class); Notification::assertSentTo($this->user, SignedInWithNewDevice::class);
@ -128,7 +128,7 @@ public function test_login_does_not_send_new_device_notification()
'email' => $this->user->email, 'email' => $this->user->email,
'password' => self::PASSWORD, 'password' => self::PASSWORD,
], [ ], [
'HTTP_USER_AGENT' => 'NotSymfony' 'HTTP_USER_AGENT' => 'NotSymfony',
])->assertOk(); ])->assertOk();
Notification::assertNothingSentTo($this->user); Notification::assertNothingSentTo($this->user);

View File

@ -3,11 +3,8 @@
namespace Tests\Unit\Listeners\Authentication; namespace Tests\Unit\Listeners\Authentication;
use App\Listeners\Authentication\LoginListener; use App\Listeners\Authentication\LoginListener;
use App\Models\User;
use Illuminate\Auth\Events\Login; use Illuminate\Auth\Events\Login;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use Mockery;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use Tests\TestCase; use Tests\TestCase;