feat(users): add suspended user warning
This commit is contained in:
parent
0f4ce2d7b0
commit
075e9492c3
@ -36,7 +36,7 @@ class Ban extends Model
|
|||||||
];
|
];
|
||||||
|
|
||||||
public $dates = [
|
public $dates = [
|
||||||
'suspendedUntil',
|
'bannedUntil',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function user()
|
public function user()
|
||||||
|
@ -174,6 +174,7 @@ class UserController extends Controller
|
|||||||
'isLocked' => $suspensionService->isLocked($user),
|
'isLocked' => $suspensionService->isLocked($user),
|
||||||
'isSuspended' => $suspensionService->isSuspended($user),
|
'isSuspended' => $suspensionService->isSuspended($user),
|
||||||
'suspensionReason' => $suspensionService->getSuspensionReason($user),
|
'suspensionReason' => $suspensionService->getSuspensionReason($user),
|
||||||
|
'suspensionDuration' => $suspensionService->getSuspensionDuration($user),
|
||||||
'has2FA' => $user->has2FA(),
|
'has2FA' => $user->has2FA(),
|
||||||
'applications' => $user->applications()->get()
|
'applications' => $user->applications()->get()
|
||||||
]);
|
]);
|
||||||
|
@ -124,7 +124,13 @@ class AccountSuspensionService
|
|||||||
return ($this->isSuspended($user)) ? $user->bans->reason : false;
|
return ($this->isSuspended($user)) ? $user->bans->reason : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSuspensionDuration(User $user): string|null {
|
||||||
|
if ($this->isSuspended($user)) {
|
||||||
|
return $user->bans->bannedUntil->diffForHumans();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Checks whether an account is locked
|
* Checks whether an account is locked
|
||||||
*
|
*
|
||||||
|
@ -342,7 +342,25 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
|
@if ($isSuspended)
|
||||||
|
<x-alert extra-styling="mb-4" alert-type="danger" icon="fa fa-exclamation-triangle" title="{{ __('Account suspended') }}" >
|
||||||
|
<p><i class="fas fa-arrow-circle-right"></i> {{ __('This account has been :suspensionType suspended.', ['suspensionType' => (is_null($suspensionDuration)) ? __('permanently') : __('temporarily') ]) }}</p>
|
||||||
|
<p><i class="fas fa-arrow-circle-right"></i> {!! __('<b>Reason: </b>:reason', ['reason' => $suspensionReason]) !!}</p>
|
||||||
|
<p><i class="fas fa-arrow-circle-right"></i> {!! __('<b>Suspension expires: </b>:duration', ['duration' => $suspensionDuration]) !!}</p>
|
||||||
|
</x-alert>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (!$isSuspended)
|
||||||
<button onclick="$('#banAccountModal').modal('show')" type="button" class="btn btn-warning mr-3"><i class="fas fa-user-slash"></i> {{ __('Suspend account') }}</button>
|
<button onclick="$('#banAccountModal').modal('show')" type="button" class="btn btn-warning mr-3"><i class="fas fa-user-slash"></i> {{ __('Suspend account') }}</button>
|
||||||
|
@else
|
||||||
|
<form class="d-inline" method="post" action="{{ route('unbanUser', ['user' => $user]) }}">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-success mr-2"><i class="fas fa-user"></i> {{ __('Unsuspend account') }}</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
<button onclick="$('#deleteAccount').modal('show')" type="button" class="btn btn-danger"><i class="fas fa-trash"></i> {{ __('Delete account') }}</button>
|
<button onclick="$('#deleteAccount').modal('show')" type="button" class="btn btn-danger"><i class="fas fa-trash"></i> {{ __('Delete account') }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user