mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-26 06:52:13 +02:00
Fix pint issues
This commit is contained in:
parent
ad43aa777b
commit
e624995ebc
@ -131,8 +131,7 @@ class GroupController extends Controller
|
||||
// are not assigned to any group record.
|
||||
if ($group->id === 0) {
|
||||
$twofaccounts = $request->user()->twofaccounts;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$twofaccounts = $group->twofaccounts;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ class GroupStoreRequest extends FormRequest
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
public function messages() : array
|
||||
{
|
||||
return [
|
||||
'name.not_in' => __('errors.reserved_name_please_choose_something_else'),
|
||||
|
@ -25,7 +25,7 @@ class GroupDeleted
|
||||
public function __construct(Group $group)
|
||||
{
|
||||
$this->group = $group;
|
||||
|
||||
|
||||
Log::info(sprintf('Group %s (id #%d) deleted ', var_export($group->name, true), $group->id));
|
||||
}
|
||||
}
|
||||
|
@ -57,14 +57,14 @@ class Helpers
|
||||
public static function lockedPreferences(array $preferences) : array
|
||||
{
|
||||
foreach ($preferences as $key => $value) {
|
||||
$_key = $key === 'revealDottedOTP' ? 'revealDottedOtp' : $key;
|
||||
$_key = $key === 'revealDottedOTP' ? 'revealDottedOtp' : $key;
|
||||
$isLocked = envUnlessEmpty(Str::of($_key)->snake('_')->upper()->prepend('USERPREF_LOCKED__')->toString(), false);
|
||||
|
||||
|
||||
if ($isLocked) {
|
||||
$lockedPreferences[] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $lockedPreferences ?? [];
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class SinglePageController extends Controller
|
||||
$publicSettings = $appSettings->only([
|
||||
'disableRegistration',
|
||||
'enableSso',
|
||||
'useSsoOnly'
|
||||
'useSsoOnly',
|
||||
]);
|
||||
$settings = $appSettings->map(function (mixed $item, string $key) {
|
||||
return null;
|
||||
|
@ -78,7 +78,7 @@ class Group extends Model
|
||||
* @var array
|
||||
*/
|
||||
protected $dispatchesEvents = [
|
||||
'deleted' => GroupDeleted::class,
|
||||
'deleted' => GroupDeleted::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@ -97,7 +97,7 @@ class Group extends Model
|
||||
Log::info(sprintf('Group %s (id #%d) updated by user ID #%s', var_export($model->name, true), $model->id, $model->user_id));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the model for a bound value.
|
||||
*
|
||||
@ -117,8 +117,7 @@ class Group extends Model
|
||||
$group->id = 0;
|
||||
|
||||
return $group;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return parent::resolveRouteBinding($value, $field);
|
||||
}
|
||||
}
|
||||
|
@ -427,16 +427,14 @@ class TwoFAccount extends Model implements Sortable
|
||||
$this->save();
|
||||
}
|
||||
} else {
|
||||
$OtpDto = new TotpDto;
|
||||
$OtpDto->otp_type = $this->otp_type;
|
||||
$OtpDto->generated_at = $time ?: time();
|
||||
$expires_in = $this->generator->expiresIn(); /** @phpstan-ignore-line - expiresIn() is in the TOTPInterface only */
|
||||
|
||||
$OtpDto = new TotpDto;
|
||||
$OtpDto->otp_type = $this->otp_type;
|
||||
$OtpDto->generated_at = $time ?: time();
|
||||
$expires_in = $this->generator->expiresIn(); /** @phpstan-ignore-line - expiresIn() is in the TOTPInterface only */
|
||||
if ($this->otp_type === self::TOTP) {
|
||||
$OtpDto->password = $this->generator->at($OtpDto->generated_at);
|
||||
$OtpDto->next_password = $this->generator->at($OtpDto->generated_at + $expires_in + 2);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$OtpDto->password = SteamTotp::getAuthCode(base64_encode(Base32::decodeUpper($this->secret)));
|
||||
$OtpDto->next_password = SteamTotp::getAuthCode(base64_encode(Base32::decodeUpper($this->secret)), $expires_in + 2);
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ class User extends Authenticatable implements HasLocalePreference, WebAuthnAuthe
|
||||
public function getPreferencesAttribute($value)
|
||||
{
|
||||
$preferences = collect(config('2fauth.preferences'))->merge(json_decode($value)); /** @phpstan-ignore-line */
|
||||
|
||||
|
||||
return $preferences;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ class GroupService
|
||||
DB::transaction(function () use ($group, $ids, $user) {
|
||||
$group = Group::sharedLock()->find($group->id);
|
||||
$twofaccounts = TwoFAccount::sharedLock()->find($ids);
|
||||
|
||||
|
||||
if (! $group) {
|
||||
throw new ModelNotFoundException('group no longer exists');
|
||||
}
|
||||
@ -71,7 +71,7 @@ class GroupService
|
||||
}
|
||||
|
||||
$group->twofaccounts()->saveMany($twofaccounts);
|
||||
|
||||
|
||||
Log::info(sprintf('Twofaccounts #%s assigned to group %s (ID #%s)', implode(',', $ids), var_export($group->name, true), $group->id));
|
||||
}, 5);
|
||||
} else {
|
||||
|
@ -120,8 +120,8 @@ class UserControllerTest extends FeatureTestCase
|
||||
->json('GET', '/api/v1/user/preferences/showOtpAsDot')
|
||||
->assertOk()
|
||||
->assertExactJson([
|
||||
'key' => 'showOtpAsDot',
|
||||
'value' => config('2fauth.preferences.showOtpAsDot'),
|
||||
'key' => 'showOtpAsDot',
|
||||
'value' => config('2fauth.preferences.showOtpAsDot'),
|
||||
'locked' => false,
|
||||
]);
|
||||
}
|
||||
@ -130,7 +130,7 @@ class UserControllerTest extends FeatureTestCase
|
||||
public function test_showPreference_returns_preference_with_locked_default_env_value()
|
||||
{
|
||||
// See .env.testing which sets USERPREF_DEFAULT__THEME=light
|
||||
// while config/2fauth.php sets the default value to 'system'
|
||||
// while config/2fauth.php sets the default value to 'system'
|
||||
|
||||
/**
|
||||
* @var \App\Models\User|\Illuminate\Contracts\Auth\Authenticatable
|
||||
@ -141,8 +141,8 @@ class UserControllerTest extends FeatureTestCase
|
||||
->json('GET', '/api/v1/user/preferences/theme')
|
||||
->assertOk()
|
||||
->assertExactJson([
|
||||
'key' => 'theme',
|
||||
'value' => 'light',
|
||||
'key' => 'theme',
|
||||
'value' => 'light',
|
||||
'locked' => true,
|
||||
]);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class GroupModelTest extends ModelTestCase
|
||||
'user_id' => 'integer',
|
||||
],
|
||||
[
|
||||
'deleted' => GroupDeleted::class,
|
||||
'deleted' => GroupDeleted::class,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ class HelpersTest extends TestCase
|
||||
public function test_lockedPreferences_returns_locked_preferences()
|
||||
{
|
||||
// See .env.testing which sets USERPREF_DEFAULT__THEME=light
|
||||
// while config/2fauth.php sets the default value to 'system'
|
||||
// while config/2fauth.php sets the default value to 'system'
|
||||
$lockedPreferences = Helpers::lockedPreferences(config('2fauth.preferences'));
|
||||
|
||||
$this->assertContains('theme', $lockedPreferences);
|
||||
|
Loading…
x
Reference in New Issue
Block a user