🆙 More fixes 🆙

This commit is contained in:
Remco
2026-01-19 20:43:46 +01:00
parent deed2158ca
commit 7b9849c159
77 changed files with 1084 additions and 13612 deletions
@@ -14,7 +14,10 @@ class CurrentPasswordRule implements InvokableRule
*/
public function __invoke(string $attribute, mixed $value, Closure $fail): void
{
if (! Hash::check($value, Auth::user()->password)) {
/** @var \App\Models\User $user */
$user = Auth::user();
if (! Hash::check(is_string($value) ? $value : '', $user->password)) {
$fail('It seems like your current password is wrong.');
}
}
@@ -8,11 +8,11 @@ use Illuminate\Contracts\Validation\InvokableRule;
class GoogleRecaptchaRule implements InvokableRule
{
public function __invoke(string $attribute, mixed $value, Closure $fail)
public function __invoke(string $attribute, mixed $value, Closure $fail): void
{
// If recaptcha is disabled
if ((int) setting('google_recaptcha_enabled') === 0) {
return true;
return;
}
$client = new Client;
@@ -29,10 +29,14 @@ class GoogleRecaptchaRule implements InvokableRule
if ($response->getStatusCode() !== 200) {
$fail(__('The Google recaptcha was not successful.'));
return;
}
/** @var \stdClass $body */
$body = json_decode((string) $response->getBody());
return $body->success;
if (! isset($body->success) || ! $body->success) {
$fail(__('The Google recaptcha was not successful.'));
}
}
}
+1 -1
View File
@@ -131,7 +131,7 @@ class Password implements Rule
/**
* Set the minimum length of the password.
*/
public function length(int $length)
public function length(int $length): static
{
$this->length = $length;
+3 -2
View File
@@ -10,10 +10,11 @@ class TurnstileCheck implements ValidationRule
{
public function validate(string $attribute, mixed $value, Closure $fail): void
{
$response = LaravelTurnstile::validate($value);
$response = LaravelTurnstile::validate(is_string($value) ? $value : '');
if (! $response['success'] && setting('cloudflare_turnstile_enabled')) {
$fail(__(config('turnstile.error_messages.turnstile_check_message')));
$message = config('turnstile.error_messages.turnstile_check_message');
$fail(__(is_string($message) ? $message : 'Turnstile check failed.'));
}
}
}
@@ -10,7 +10,10 @@ class ValidateInstallationKeyRule implements ValidationRule
{
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if ($value !== WebsiteInstallation::first()->installation_key) {
/** @var WebsiteInstallation|null $installation */
$installation = WebsiteInstallation::first();
if (! $installation || $value !== $installation->installation_key) {
$fail('The :attribute does not match');
}
}
@@ -9,14 +9,17 @@ use Illuminate\Support\Str;
class WebsiteWordfilterRule implements InvokableRule
{
public function __invoke(string $attribute, mixed $value, Closure $fail)
public function __invoke(string $attribute, mixed $value, Closure $fail): void
{
$words = WebsiteWordfilter::get()
->pluck('word')
->toArray();
/** @var array<string> $words */
$words = WebsiteWordfilter::pluck('word')->map(fn ($item) => is_scalar($item) ? (string) $item : '')->all();
if (setting('website_wordfilter_enabled') === '1' && in_array(strtolower((string) $value), $words) || Str::contains(strtolower((string) $value), $words)) {
$fail(__('You entered something that is not allowed on :hotel', ['hotel' => setting('hotel_name')]));
if (setting('website_wordfilter_enabled') === '1') {
$stringValue = strtolower(is_scalar($value) ? (string) $value : '');
if (in_array($stringValue, $words) || Str::contains($stringValue, $words)) {
$fail(__('You entered something that is not allowed on :hotel', ['hotel' => setting('hotel_name')]));
}
}
}
}