mirror of
https://github.com/flarum/framework.git
synced 2024-11-28 20:16:08 +08:00
Only validate and check for suspend permission if suspendUntil attribute is present. fixes flarum/core#826
This commit is contained in:
parent
f0f668938a
commit
a87b51f511
|
@ -10,8 +10,7 @@
|
||||||
|
|
||||||
namespace Flarum\Suspend\Listener;
|
namespace Flarum\Suspend\Listener;
|
||||||
|
|
||||||
use Illuminate\Support\Arr;
|
use DateTime;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Flarum\Core\Access\AssertPermissionTrait;
|
use Flarum\Core\Access\AssertPermissionTrait;
|
||||||
use Flarum\Event\UserWillBeSaved;
|
use Flarum\Event\UserWillBeSaved;
|
||||||
use Flarum\Suspend\SuspendValidator;
|
use Flarum\Suspend\SuspendValidator;
|
||||||
|
@ -51,11 +50,7 @@ class SaveSuspensionToDatabase
|
||||||
{
|
{
|
||||||
$attributes = array_get($event->data, 'attributes', []);
|
$attributes = array_get($event->data, 'attributes', []);
|
||||||
|
|
||||||
$suspendUntil = Arr::get($attributes, 'suspendUntil');
|
if (array_key_exists('suspendUntil', $attributes)) {
|
||||||
if ($suspendUntil) {
|
|
||||||
$suspendUntil = new Carbon($suspendUntil);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->validator->assertValid($attributes);
|
$this->validator->assertValid($attributes);
|
||||||
|
|
||||||
$user = $event->user;
|
$user = $event->user;
|
||||||
|
@ -63,6 +58,7 @@ class SaveSuspensionToDatabase
|
||||||
|
|
||||||
$this->assertCan($actor, 'suspend', $user);
|
$this->assertCan($actor, 'suspend', $user);
|
||||||
|
|
||||||
$user->suspend_until = $suspendUntil;
|
$user->suspend_until = new DateTime($attributes['suspendUntil']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user