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