diff --git a/app/Http/Controllers/Auth/EveLoginController.php b/app/Http/Controllers/Auth/EveLoginController.php index cf8ff8d..7e60bb4 100644 --- a/app/Http/Controllers/Auth/EveLoginController.php +++ b/app/Http/Controllers/Auth/EveLoginController.php @@ -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 diff --git a/app/Http/Controllers/Dashboard/DashboardController.php b/app/Http/Controllers/Dashboard/DashboardController.php index bed2f79..b4311ac 100644 --- a/app/Http/Controllers/Dashboard/DashboardController.php +++ b/app/Http/Controllers/Dashboard/DashboardController.php @@ -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() { diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php new file mode 100644 index 0000000..08ddef3 --- /dev/null +++ b/app/Http/Middleware/Authenticate.php @@ -0,0 +1,24 @@ +auth->check()) { + return '/'; + } + + return $next($request); + } +} diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php new file mode 100644 index 0000000..22bd60f --- /dev/null +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -0,0 +1,24 @@ +check()) { + return redirect()->to('/dashboard'); + } + + return $next($request); + } +} diff --git a/app/Models/Auth/AvailableUserPermission.php b/app/Models/Auth/AvailableUserPermission.php index f5033f2..bd7dcee 100644 --- a/app/Models/Auth/AvailableUserPermission.php +++ b/app/Models/Auth/AvailableUserPermission.php @@ -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 diff --git a/app/Models/Auth/AvailableUserRole.php b/app/Models/Auth/AvailableUserRole.php index b6619f3..50320bf 100644 --- a/app/Models/Auth/AvailableUserRole.php +++ b/app/Models/Auth/AvailableUserRole.php @@ -13,7 +13,7 @@ class AvailableUserRole extends Model public $primaryKey = 'id'; //Timestamps - public $timestamps = false; + public $timestamps = true; /** * The attribute that are mass assignable diff --git a/app/Models/Auth/UserPermission.php b/app/Models/Auth/UserPermission.php index 6b4df22..57c73cd 100644 --- a/app/Models/Auth/UserPermission.php +++ b/app/Models/Auth/UserPermission.php @@ -14,6 +14,8 @@ class UserPermission extends Model //Primary Key public $primaryKey = 'id'; + public $timestamps = true; + /** * The attributes that are mass assignable * diff --git a/app/Models/Auth/UserRole.php b/app/Models/Auth/UserRole.php index 3b0ad37..38099b4 100644 --- a/app/Models/Auth/UserRole.php +++ b/app/Models/Auth/UserRole.php @@ -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() { diff --git a/database/migrations/2026_03_11_034937_create_user_roles_permissions.php b/database/migrations/2026_03_11_034937_create_user_roles_permissions.php new file mode 100644 index 0000000..add431b --- /dev/null +++ b/database/migrations/2026_03_11_034937_create_user_roles_permissions.php @@ -0,0 +1,70 @@ +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'); + } +}; diff --git a/resources/views/dashboard/dashboard.blade.php b/resources/views/dashboard/dashboard.blade.php index 0909d60..b2e4f61 100644 --- a/resources/views/dashboard/dashboard.blade.php +++ b/resources/views/dashboard/dashboard.blade.php @@ -20,6 +20,9 @@
Privileges version: {{ auth()->user()->privileges_version }}
JWT issued at: {{ optional(auth()->user()->user_jwt_issued_at)?->toDateTimeString() }}
JWT expires at: {{ optional(auth()->user()->user_jwt_expires_at)?->toDateTimeString() }}
+ @if(session()->has('Token')) +Token: {{ session('Token') }}
+ @endif