feat(users): add account indicators to management page, update old refs
This commit is contained in:
parent
e691e61bb5
commit
2b79ae4d09
@ -33,11 +33,6 @@ class Application extends Model
|
|||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public function oneoffApplicant()
|
|
||||||
{
|
|
||||||
return $this->hasOne('App\OneoffApplicant', 'application_id', 'id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function user()
|
public function user()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('App\User', 'applicantUserID', 'id');
|
return $this->belongsTo('App\User', 'applicantUserID', 'id');
|
||||||
@ -70,11 +65,4 @@ class Application extends Model
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function isOneoff()
|
|
||||||
{
|
|
||||||
return $this->user->id == 1; // ID 1 is always the ghost
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -127,12 +127,15 @@ class RegisterController extends Controller
|
|||||||
*/
|
*/
|
||||||
protected function create(array $data)
|
protected function create(array $data)
|
||||||
{
|
{
|
||||||
|
$ip = IP::shouldCollect() ? request()->ip() : '0.0.0.0';
|
||||||
|
|
||||||
$user = User::create([
|
$user = User::create([
|
||||||
'uuid' => $data['uuid'] ?? "disabled",
|
'uuid' => $data['uuid'] ?? "disabled",
|
||||||
'name' => $data['name'],
|
'name' => $data['name'],
|
||||||
'email' => $data['email'],
|
'email' => $data['email'],
|
||||||
'password' => Hash::make($data['password']),
|
'password' => Hash::make($data['password']),
|
||||||
'originalIP' => IP::shouldCollect() ? request()->ip() : '0.0.0.0',
|
'registrationIp' => $ip,
|
||||||
|
'currentIp' => $ip
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$user->assignRole('user');
|
$user->assignRole('user');
|
||||||
|
@ -100,7 +100,7 @@ class ProfileController extends Controller
|
|||||||
'insta' => $socialMediaProfiles['links']['insta'] ?? 'UpdateMe',
|
'insta' => $socialMediaProfiles['links']['insta'] ?? 'UpdateMe',
|
||||||
'discord' => $socialMediaProfiles['links']['discord'] ?? 'UpdateMe#12345',
|
'discord' => $socialMediaProfiles['links']['discord'] ?? 'UpdateMe#12345',
|
||||||
'since' => $createdDate->englishMonth.' '.$createdDate->year,
|
'since' => $createdDate->englishMonth.' '.$createdDate->year,
|
||||||
'ipInfo' => IP::lookup($user->originalIP),
|
'ipInfo' => IP::lookup($user->currentIp),
|
||||||
'roles' => $roleList,
|
'roles' => $roleList,
|
||||||
'suspensionInfo' => $suspensionInfo
|
'suspensionInfo' => $suspensionInfo
|
||||||
]);
|
]);
|
||||||
|
@ -61,7 +61,7 @@ class UserController extends Controller
|
|||||||
{
|
{
|
||||||
$this->authorize('viewPlayers', User::class);
|
$this->authorize('viewPlayers', User::class);
|
||||||
|
|
||||||
return view('dashboard.administration.players')
|
return view('dashboard.administration.users')
|
||||||
->with([
|
->with([
|
||||||
'users' => User::with('roles')->paginate('6'),
|
'users' => User::with('roles')->paginate('6'),
|
||||||
'numUsers' => count(User::all()),
|
'numUsers' => count(User::all()),
|
||||||
@ -91,7 +91,7 @@ class UserController extends Controller
|
|||||||
if (! $matchingUsers->isEmpty()) {
|
if (! $matchingUsers->isEmpty()) {
|
||||||
$request->session()->flash('success', __('There were :usersCount user(s) matching your search.', ['usersCount' => $matchingUsers->count()]));
|
$request->session()->flash('success', __('There were :usersCount user(s) matching your search.', ['usersCount' => $matchingUsers->count()]));
|
||||||
|
|
||||||
return view('dashboard.administration.players')
|
return view('dashboard.administration.users')
|
||||||
->with([
|
->with([
|
||||||
'users' => $matchingUsers,
|
'users' => $matchingUsers,
|
||||||
'numUsers' => count(User::all()),
|
'numUsers' => count(User::all()),
|
||||||
@ -170,7 +170,12 @@ class UserController extends Controller
|
|||||||
->with([
|
->with([
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'roles' => $roleList,
|
'roles' => $roleList,
|
||||||
'ipInfo' => IP::lookup($request->ip())
|
'isVerified' => $user->isVerified(),
|
||||||
|
'isLocked' => $suspensionService->isLocked($user),
|
||||||
|
'isSuspended' => $suspensionService->isSuspended($user),
|
||||||
|
'suspensionReason' => $suspensionService->getSuspensionReason($user),
|
||||||
|
'has2FA' => $user->has2FA(),
|
||||||
|
'applications' => $user->applications()->get()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,6 +420,7 @@ class UserController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Demote the given user's privileges
|
* Demote the given user's privileges
|
||||||
*
|
*
|
||||||
|
* @deprecated This method is being removed in a future version
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
@ -467,7 +473,7 @@ class UserController extends Controller
|
|||||||
|
|
||||||
if (!$suspensionService->isSuspended($user)) {
|
if (!$suspensionService->isSuspended($user)) {
|
||||||
|
|
||||||
$suspensionService->suspend($request->reason, $request->duration, $user, $request->suspensionType);
|
$suspensionService->suspend($user, $request->reason, $user, $request->suspensionType);
|
||||||
$request->session()->flash('success', __('Account suspended.'));
|
$request->session()->flash('success', __('Account suspended.'));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use App\Services\AccountSuspensionService;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
@ -35,10 +36,10 @@ class ForceLogoutMiddleware
|
|||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next)
|
public function handle($request, Closure $next)
|
||||||
{
|
{
|
||||||
if (Auth::user()->isBanned()) {
|
|
||||||
Auth::logout();
|
|
||||||
|
|
||||||
$request->session()->flash('error', __('Your account is suspended. You will not be able to login or register until the suspension is lifted.'));
|
if ((new AccountSuspensionService())->isSuspended(Auth::user())) {
|
||||||
|
Auth::logout();
|
||||||
|
$request->session()->flash('error', __('Your account is suspended. If you think this was a mistake, please contact an admin.'));
|
||||||
|
|
||||||
return redirect('/');
|
return redirect('/');
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{__('Name')}}</th>
|
<th>{{__('Name')}}</th>
|
||||||
<th>{{ __('Rank') }}</th>
|
<th>{{ __('Role') }}</th>
|
||||||
<th>{{__('Status')}}</th>
|
|
||||||
<th>{{__('Registration date')}}</th>
|
<th>{{__('Registration date')}}</th>
|
||||||
<th>{{__('Actions')}}</th>
|
<th>{{__('Actions')}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -98,9 +97,6 @@
|
|||||||
<span class="badge-warning badge"><i class="fas fa-user"></i> {{ __('Member') }}</span>
|
<span class="badge-warning badge"><i class="fas fa-user"></i> {{ __('Member') }}</span>
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td>
|
|
||||||
<x-account-status user-id="{{ $user->id }}"></x-account-status>
|
|
||||||
</td>
|
|
||||||
<td>{{$user->created_at}}</td>
|
<td>{{$user->created_at}}</td>
|
||||||
<td>
|
<td>
|
||||||
<button type="button" class="btn btn-sm btn-success" onclick="window.location.href='{{route('showSingleProfile', ['user' => $user->id])}}'"><i class="fa fa-eye"></i> {{ __('View') }}</button>
|
<button type="button" class="btn btn-sm btn-success" onclick="window.location.href='{{route('showSingleProfile', ['user' => $user->id])}}'"><i class="fa fa-eye"></i> {{ __('View') }}</button>
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<label for="reason">{{__('Public note')}}</label>
|
<label for="reason">{{__('Reason')}}</label>
|
||||||
<input type="text" name="reason" id="reason" class="form-control" placeholder="{{__('e.g. Spamming')}}">
|
<input type="text" name="reason" id="reason" class="form-control" placeholder="{{__('e.g. Spamming')}}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -54,7 +54,7 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<x-slot name="modalFooter">
|
<x-slot name="modalFooter">
|
||||||
<button id="banAccountButton" type="button" class="btn btn-danger" {{ ($demoActive) ? 'disabled' : '' }} ><i class="fa fa-gavel"></i> {{__('Confirm')}}</button>
|
<button onclick="$('#banAccountForm').submit()" id="banAccountButton" type="button" class="btn btn-danger" {{ ($demoActive) ? 'disabled' : '' }} ><i class="fa fa-gavel"></i> {{__('Confirm')}}</button>
|
||||||
</x-slot>
|
</x-slot>
|
||||||
|
|
||||||
</x-modal>
|
</x-modal>
|
||||||
@ -184,7 +184,7 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
|
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3>{{ __('Personal details') }}</h3>
|
<h3><i class="fas fa-user-alt"></i> {{ __('Personal details') }}</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@ -197,11 +197,6 @@
|
|||||||
|
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<label for="uemail">{{ __('Account email') }}</label>
|
<label for="uemail">{{ __('Account email') }}</label>
|
||||||
@if(!is_null($user->email_verified_at))
|
|
||||||
<span class="badge badge-success ml-2"><i class="fas fa-check-square"> </i> {{ __('Verified') }}</span>
|
|
||||||
@else
|
|
||||||
<span class="badge badge-danger ml-2"><i class="fas fa-exclamation-circle"></i> {{ __('Not verified') }}</span>
|
|
||||||
@endif
|
|
||||||
<input id="uemail" type="email" class="form-control" value="{{ $user->email }}" disabled>
|
<input id="uemail" type="email" class="form-control" value="{{ $user->email }}" disabled>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -209,17 +204,30 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<label for="uip">{{ __('Current IP address') }}</label>
|
<label for="uip">{{ __('Current IP') }}</label>
|
||||||
<input type="text" class="form-control" id="uip" value="{{ $user->originalIP }}" disabled>
|
<input type="text" class="form-control" id="uip" value="{{ $user->currentIp }}" disabled>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<label for="uip">{{ __('Registration IP') }}</label>
|
||||||
|
<input type="text" class="form-control" id="uip" value="{{ (empty($user->registrationIp)) ? __('Unavailable') : $user->registrationIp }}" disabled>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<label for="uregdate">{{ __('Registration date') }}</label>
|
<label for="uregdate">{{ __(' Registered at') }}</label>
|
||||||
<input id="uregdate" class="form-control" type="text" value="{{ $user->created_at }}" disabled>
|
<input id="uregdate" class="form-control" type="text" value="{{ $user->created_at }} ({{ $user->created_at->diffForHumans() }})" disabled>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-2">
|
||||||
|
<label>{{ __('Account indicators') }}</label>
|
||||||
|
<x-account-status is-verified="{{ $isVerified }}" is-locked="{{ $isLocked }}" is-suspended="{{ $isSuspended }}" has2-f-a="{{ $has2FA }}" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-footer">
|
||||||
|
<button onclick="$('#editUser').modal('show')" type="button" class="btn btn-warning"><i class="fas fa-pencil-alt"></i> {{ __('Edit account details') }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -227,6 +235,120 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row mt-5">
|
||||||
|
<div class="col">
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h3><i class="fas fa-clipboard"></i> {{ __('Application history') }}</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-body">
|
||||||
|
@if (!$applications->isEmpty())
|
||||||
|
|
||||||
|
<table class="table table-borderless" style="whitespace: nowrap">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th>#</th>
|
||||||
|
<th>{{__('Status')}}</th>
|
||||||
|
<th>{{ __('Vacancy') }}</th>
|
||||||
|
<th>{{__('Date')}}</th>
|
||||||
|
<th>{{__('Actions')}}</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
@foreach($applications as $application)
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>{{ $application->id }}</td>
|
||||||
|
<td>
|
||||||
|
@switch($application->applicationStatus)
|
||||||
|
|
||||||
|
@case('STAGE_SUBMITTED')
|
||||||
|
|
||||||
|
<span class="badge badge-primary"><i class="far fa-clock"></i> {{__('Outstanding (Submitted)')}}</span>
|
||||||
|
@break
|
||||||
|
|
||||||
|
@case('STAGE_PEERAPPROVAL')
|
||||||
|
|
||||||
|
<span class="badge badge-warning"><i class="fas fa-vote-yea"></i> {{__('Peer Review')}}</span>
|
||||||
|
@break
|
||||||
|
|
||||||
|
@case('STAGE_INTERVIEW')
|
||||||
|
|
||||||
|
<span class="badge badge-warning"><i class="fas fa-microphone-alt"></i> {{__('Interview')}}</span>
|
||||||
|
|
||||||
|
@break
|
||||||
|
|
||||||
|
@case('STAGE_INTERVIEW_SCHEDULED')
|
||||||
|
|
||||||
|
<span class="badge badge-warning"><i class="far fa-clock"></i>{{__('Interview Scheduled')}}</span>
|
||||||
|
|
||||||
|
@break
|
||||||
|
|
||||||
|
@case('APPROVED')
|
||||||
|
|
||||||
|
<span class="badge badge-success"><i class="fas fa-check"></i> {{__('Approved')}}</span>
|
||||||
|
|
||||||
|
@break
|
||||||
|
|
||||||
|
@case('DENIED')
|
||||||
|
|
||||||
|
<span class="badge badge-danger"><i class="fas fa-times"></i> {{__('Denied')}}</span>
|
||||||
|
|
||||||
|
@break;
|
||||||
|
|
||||||
|
@default
|
||||||
|
<span class="badge badge-secondary"><i class="fas fa-question-circle"></i> {{__('Denied')}}</span>
|
||||||
|
|
||||||
|
@endswitch
|
||||||
|
</td>
|
||||||
|
<td>{{ $application->response->vacancy->vacancyName }}</td>
|
||||||
|
<td>{{ $application->created_at }} ({{ $application->created_at->diffForHumans() }})</td>
|
||||||
|
<td>
|
||||||
|
<x-button id="view" link="{{ route('showUserApp', ['application' => $application->id]) }}" icon="fas fa-eye" target="_blank" color="success" size="sm">
|
||||||
|
{{ __('View') }}
|
||||||
|
</x-button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
@else
|
||||||
|
<x-alert alert-type="warning" icon="fas fa-exclamation-triangle" title="{{ __('No applications') }}">
|
||||||
|
{{ __('This user has not submitted any applications yet.') }}
|
||||||
|
</x-alert>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row mt-5 mb-5">
|
||||||
|
<div class="col">
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h3><i class="fas fa-shield-alt"></i> {{ __('Moderation actions') }}</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-body">
|
||||||
|
<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="$('#deleteAccount').modal('show')" type="button" class="btn btn-danger"><i class="fas fa-trash"></i> {{ __('Delete account') }}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@stop
|
@stop
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user