dashboard and login controller for alts
This commit is contained in:
@@ -99,7 +99,9 @@ class LoginController extends Controller
|
||||
$this->SetScopes($ssoUser->user['Scopes'], $ssoUser->id);
|
||||
|
||||
return redirect()->to('/dashboard')->with('success', 'Successfully updated ESI Scopes.');
|
||||
}
|
||||
} else {
|
||||
$this->createAlt($ssoUser);
|
||||
}
|
||||
} else {
|
||||
$user = $this->createOrGetUser($ssoUser);
|
||||
|
||||
@@ -115,7 +117,7 @@ class LoginController extends Controller
|
||||
*
|
||||
* @param \Laravel\Socialite\Two\User $user
|
||||
*/
|
||||
private function createOrGetAlt($user) {
|
||||
private function createAlt($user) {
|
||||
$altCount = UserAlt::where('character_id', $user->id)->count();
|
||||
if($altcount == 0) {
|
||||
$newAlt = new UserAlt;
|
||||
|
||||
@@ -118,16 +118,53 @@ class DashboardController extends Controller
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function profile() {
|
||||
$scopes = EsiScope::where('character_id', Auth()->user()->character_id)->get();
|
||||
$permissions = UserPermission::where('character_id', Auth()->user()->characer_id)->get();
|
||||
$roles = UserRole::where('character_id', Auth()->user()->character_id)->get();
|
||||
|
||||
$data = [
|
||||
'scopes' => $scopes,
|
||||
'permissions' => $permissions,
|
||||
'roles' => $roles,
|
||||
];
|
||||
//Declare some variables
|
||||
$alts = null;
|
||||
$scopes = null;
|
||||
$permissions = null;
|
||||
$roles = null;
|
||||
|
||||
return view('dashboard.profile')->with('data', $data);
|
||||
//Get the Esi scopes, user permission set, and roles
|
||||
$scopeCount = EsiScope::where('character_id', auth()->user()->character_id)->count();
|
||||
if($scopeCount > 0) {
|
||||
$scopes = EsiScope::where('character_id', Auth()->user()->character_id)->get();
|
||||
}
|
||||
|
||||
$permissionCount = UserPermission::where('character_id', auth()->user()->character_id)->count();
|
||||
if($permissionCount > 0) {
|
||||
$permissions = UserPermission::where('character_id', Auth()->user()->characer_id)->get();
|
||||
}
|
||||
|
||||
$roleCount = UserRole::where('character_id', auth()->user()->character_id)->count();
|
||||
if($roleCount > 0) {
|
||||
$roles = UserRole::where('character_id', Auth()->user()->character_id)->get();
|
||||
}
|
||||
|
||||
$altCount = UserAlt::where('main_id', auth()->user()->character_id)->count();
|
||||
if($altCount > 0) {
|
||||
$alts = UserAlt::where(['main_id' => auth()->user()->character_id])->get();
|
||||
}
|
||||
|
||||
return view('dashboard.profile')->with('scopeCount', $scopeCount)
|
||||
->with('scopes', $scopes)
|
||||
->with('permissionCount', $permissionCount)
|
||||
->with('permissions', $permissions)
|
||||
->with('roleCount', $roleCount)
|
||||
->with('roles', $roles)
|
||||
->with('altCount', $altCount)
|
||||
->with('alts', $alts);
|
||||
}
|
||||
|
||||
public function removeAlt(Request $request) {
|
||||
$this->validate($request, [
|
||||
'character' => 'required',
|
||||
]);
|
||||
|
||||
UserAlt::where([
|
||||
'main_id' => auth()->user()->character_id,
|
||||
'character_id' => $request->character,
|
||||
])->delete();
|
||||
|
||||
return redirect('/dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,122 @@
|
||||
@extends('layouts.b4')
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<h2>Services Profile</h2><br>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>Scopes</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<th>Scope</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@if($scopeCount > 0)
|
||||
@foreach($scopes as $scope)
|
||||
<tr>
|
||||
<td>{{ $scope->scope }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@else
|
||||
<tr>
|
||||
<td>No Scopes</td>
|
||||
</tr>
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>Permissions</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<th>Permission</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@if($permissionCount > 0)
|
||||
@foreach($permissions as $permission)
|
||||
<tr>
|
||||
<td>{{ $permission->permission }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@else
|
||||
<tr>
|
||||
<td>No Permissions</td>
|
||||
</tr>
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>Roles</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<th>Role</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@if($roleCount > 0)
|
||||
@foreach($roles as $role)
|
||||
<tr>
|
||||
<td>{{ $role->role }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@else
|
||||
<tr>
|
||||
<td>No Role</td>
|
||||
</tr>
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<a href="/login" img='/img/eve-soo-login-white-large.png'>Register Alt</a>
|
||||
</div>
|
||||
<br>
|
||||
<div class="container">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<th>Alt Name</th>
|
||||
<th>Character Id</th>
|
||||
<th>Remove</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@if($altcount > 0)
|
||||
@foreach($alts as $alt)
|
||||
{{ Form::open(['action' => 'Dashboard\DashboardController@removeAlt', 'method' => 'POST']) }}
|
||||
<tr>
|
||||
<td>{{ $alt->name }}</td>
|
||||
<td>{{ $alt->character_id }}</td>
|
||||
<td>
|
||||
{{ Form::hidden('character', $alt->character_id) }}
|
||||
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
|
||||
</td>
|
||||
</tr>
|
||||
{{ Form::close() }}
|
||||
@endforeach
|
||||
@else
|
||||
<tr>
|
||||
<td>No Alts on Record</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -24,6 +24,7 @@ Route::group(['middleware' => ['auth']], function(){
|
||||
* Dashboard Controller Display pages
|
||||
*/
|
||||
Route::get('/dashboard', 'Dashboard\DashboardController@index');
|
||||
Route::post('/dashboard/alt/delete', 'Dashboard\DashboardController@removeAlt');
|
||||
|
||||
/**
|
||||
* AJAX Test pages
|
||||
|
||||
Reference in New Issue
Block a user