This commit is contained in:
2026-03-10 23:52:54 -05:00
parent 4a36839794
commit b44bfaa223
10 changed files with 139 additions and 6 deletions

View File

@@ -119,6 +119,14 @@ class EveLoginController extends Controller
]
);
UserRole::updateOrCreate(
['character_id' => $charcter_id],
[
'role' => 'Guest',
'rank' => 0,
]
);
$privilege->privilegesChanged($user);
//Send the object back to the calling function

View File

@@ -21,8 +21,8 @@ use App\Models\Auth\UserRole;
class DashboardController extends Controller
{
public function __construct() {
$this->middleware('auth');
$this->middleware('role:User');
//$this->middleware('auth');
//$this->middleware('role:User');
}
public function displayDashboard() {

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class Authenticate
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
if(!$this->auth->check()) {
return '/';
}
return $next($request);
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next, $guard = null): Response
{
if (Auth::guard($guard)->check()) {
return redirect()->to('/dashboard');
}
return $next($request);
}
}

View File

@@ -20,7 +20,7 @@ class AvailableUserPermission extends Model
/**
* Timestamps enabled for the rows
*/
public $timestamps = false;
public $timestamps = true;
/**
* The attributes that are mass assignable

View File

@@ -13,7 +13,7 @@ class AvailableUserRole extends Model
public $primaryKey = 'id';
//Timestamps
public $timestamps = false;
public $timestamps = true;
/**
* The attribute that are mass assignable

View File

@@ -14,6 +14,8 @@ class UserPermission extends Model
//Primary Key
public $primaryKey = 'id';
public $timestamps = true;
/**
* The attributes that are mass assignable
*

View File

@@ -12,7 +12,9 @@ class UserRole extends Model
protected $table = 'user_roles';
//Primary Key
public $primaryKey = 'id';
public $primaryKey = 'character_id';
public $timestamps = true;
/**
* Attributes which are mass assignable
@@ -20,8 +22,8 @@ class UserRole extends Model
* @var array
*/
protected $fillable = [
'character_id',
'role',
'rank',
];
public function user() {

View File

@@ -0,0 +1,70 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
if(!Schema::hasTable('available_user_roles')) {
Schema::createTable('available_user_roles', function (Blueprint $table) {
$table->increments('id');
$table->string('role');
$table->string('description');
$table->timestamps();
});
}
if(!Schema::hasTable('user_roles')) {
Schema::createTable('user_roles', function (Blueprint $table) {
$table->unsignedBigInteger('character_id')->unique();
$table->string('role')->default('Guest');
$table->timestamps();
$table->foreign('character_id', 'fk_user_roles_character_id')
->references('character_id')
->on('users')
->cascadeOnDelete();
});
}
if(!Schema::hasTable('user_permissions')) {
Schema::createTable('user_permissions', function (Blueprint $table) {
$table->increments('id');
$table->unsignedBigInteger('character_id');
$table->string('permission');
$table->timestamps();
$table->foreign('character_id', 'fk_user_permissions_character_id')
->references('character_id')
->on('users')
->cascadeOnDelete();
});
}
if(!Schema::hasTable('available_user_permissions')) {
Schema::createTable('available_user_permissions', function (Blueprint $table) {
$table->increments('id');
$table->string('permission');
$table->text('description');
$table->timestamps();
})
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('user_roles');
Schema::dropIfExists('user_permissions');
Schema::dropIfExists('available_user_roles');
Schema::dropIfExists('available_user_permissions');
}
};

View File

@@ -20,6 +20,9 @@
<p>Privileges version: <strong>{{ auth()->user()->privileges_version }}</strong></p>
<p>JWT issued at: <strong>{{ optional(auth()->user()->user_jwt_issued_at)?->toDateTimeString() }}</strong></p>
<p>JWT expires at: <strong>{{ optional(auth()->user()->user_jwt_expires_at)?->toDateTimeString() }}</strong></p>
@if(session()->has('Token'))
<p>Token: {{ session('Token') }}</p>
@endif
</div>
</body>