allowed login models and update of login controller
This commit is contained in:
@@ -12,7 +12,7 @@ use DB;
|
|||||||
use App\User;
|
use App\User;
|
||||||
use App\Models\Esi\EsiScope;
|
use App\Models\Esi\EsiScope;
|
||||||
use App\Models\Esi\EsiToken;
|
use App\Models\Esi\EsiToken;
|
||||||
use App\Models\User\UserRole;
|
use App\Models\user\Permission;
|
||||||
|
|
||||||
use Seat\Eseye\Cache\NullCache;
|
use Seat\Eseye\Cache\NullCache;
|
||||||
use Seat\Eseye\Configuration;
|
use Seat\Eseye\Configuration;
|
||||||
@@ -111,6 +111,12 @@ class LoginController extends Controller
|
|||||||
'owner_hash' => $eve_user->owner_hash,
|
'owner_hash' => $eve_user->owner_hash,
|
||||||
'role' => $role,
|
'role' => $role,
|
||||||
]);
|
]);
|
||||||
|
//Update the user's roles and permission
|
||||||
|
UserPermission::where(['character_id' => $eve_user->id])->delete();
|
||||||
|
$perm = new UserPermission();
|
||||||
|
$perm->character_id = $eve_user->id;
|
||||||
|
$perm->permission = $role;
|
||||||
|
$perm->save();
|
||||||
} else {
|
} else {
|
||||||
//Update the user information never the less.
|
//Update the user information never the less.
|
||||||
DB::table('users')->where('character_id', $eve_user->id)->update([
|
DB::table('users')->where('character_id', $eve_user->id)->update([
|
||||||
@@ -178,11 +184,10 @@ class LoginController extends Controller
|
|||||||
* @param charId
|
* @param charId
|
||||||
*/
|
*/
|
||||||
private function SetRole($role, $charId) {
|
private function SetRole($role, $charId) {
|
||||||
//Insert the role into the database
|
$permission = new UserPermission;
|
||||||
$roles = new UserRole;
|
$permission->character_id = $charId;
|
||||||
$roles->character_id = $charId;
|
$permission->permission = $role;
|
||||||
$roles->role = $role;
|
$permission->save();
|
||||||
$roles->save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -226,13 +231,13 @@ class LoginController extends Controller
|
|||||||
private function GetRole($refreshToken, $charId) {
|
private function GetRole($refreshToken, $charId) {
|
||||||
$accountType = $this->GetAccountType($refreshToken, $charId);
|
$accountType = $this->GetAccountType($refreshToken, $charId);
|
||||||
if($accountType == 'Guest') {
|
if($accountType == 'Guest') {
|
||||||
$role = 'Guest';
|
$role = 'role.guest';
|
||||||
} else if($accountType == 'Legacy'){
|
} else if($accountType == 'Legacy'){
|
||||||
$role = 'User';
|
$role = 'role.user';
|
||||||
} else if($accountType == 'W4RP') {
|
} else if($accountType == 'W4RP') {
|
||||||
$role = 'User';
|
$role = 'role.user';
|
||||||
} else {
|
} else {
|
||||||
$role = 'None';
|
$role = 'role.none';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $role;
|
return $role;
|
||||||
|
|||||||
@@ -62,13 +62,8 @@ class RegisterController extends Controller
|
|||||||
* @param array $data
|
* @param array $data
|
||||||
* @return \App\User
|
* @return \App\User
|
||||||
*/
|
*/
|
||||||
protected function create(array $data)
|
protected function create()
|
||||||
{
|
{
|
||||||
return User::create([
|
|
||||||
'name' => $data['name'],
|
|
||||||
'email' => $data['email'],
|
|
||||||
'password' => Hash::make($data['password']),
|
|
||||||
'character_id' => $data['characterid'],
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Models\Admin;
|
namespace App;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class AllowedLogin extends Model
|
class AllowedLogin extends Model
|
||||||
{
|
{
|
||||||
// Table Name
|
//Table Name
|
||||||
public $table = 'allowed_login';
|
public $table = 'allowed_logins';
|
||||||
|
|
||||||
// Timestamps
|
//Timestamps
|
||||||
public $timestamps = true;
|
public $timestamps = true;
|
||||||
|
|
||||||
/**
|
|
||||||
* The attributes that are mass assignable
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'entity_id',
|
'entity_id',
|
||||||
'entity_type',
|
'entity_type',
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use Illuminate\Contracts\Auth\Access\Gate as GateContract;
|
|||||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
|
|
||||||
use DB;
|
use DB;
|
||||||
use App\Models\User\UserRole;
|
use App\Models\User\UserPermission;
|
||||||
|
|
||||||
class AuthServiceProvider extends ServiceProvider
|
class AuthServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
@@ -32,54 +32,53 @@ class AuthServiceProvider extends ServiceProvider
|
|||||||
$this->registerPolicies($gate);
|
$this->registerPolicies($gate);
|
||||||
|
|
||||||
$gate->define('isAdmin', function($user) {
|
$gate->define('isAdmin', function($user) {
|
||||||
//Get the roles the user has from the user_roles table and check against the gate we are creating
|
|
||||||
$check = UserRole::where('character_id', auth()->user()->character_id)->get(['role']);
|
$check = UserPermission::where('character_id', auth()->user()->character_id)->get(['role']);
|
||||||
if($check[0]->role === 'Admin') {
|
if($check[0]-> role === 'role.admin') {
|
||||||
//User has the Admin role
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$gate->define('isDirector', function($user) {
|
$gate->define('isDirector', function($user) {
|
||||||
//Get the roles the user has from the user_roles table and check against the gate we are creating
|
|
||||||
$check = UserRole::where('character_id', auth()->user()->character_id)->get(['role']);
|
$check = UserPermission::where('character_id', auth()->user()->character_id)->get(['role']);
|
||||||
if($check[0]->role === 'Director') {
|
if($check[0]-> role === 'role.director') {
|
||||||
//User has the Director role
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$gate->define('isUser', function($user) {
|
$gate->define('isUser', function($user) {
|
||||||
//Get the roles the user has from the user_roles table and check against the gate we are creating
|
|
||||||
$check = UserRole::where('character_id', auth()->user()->character_id)->get(['role']);
|
$check = UserPermission::where('character_id', auth()->user()->character_id)->get(['role']);
|
||||||
if($check[0]->role === 'User') {
|
if($check[0]-> role === 'role.user') {
|
||||||
//User has the User role
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$gate->define('isGuest', function($user) {
|
$gate->define('isGuest', function($user) {
|
||||||
//Get the roles the user has from the user_roles table and check against the gate we are creating
|
|
||||||
$check = UserRole::where('character_id', auth()->user()->character_id)->get(['role']);
|
$check = UserPermission::where('character_id', auth()->user()->character_id)->get(['role']);
|
||||||
if($check[0]->role === 'Guest') {
|
if($check[0]-> role === 'role.guest') {
|
||||||
//User has the Guest role
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$gate->define('isNone', function($user) {
|
$gate->define('isNone', function($user) {
|
||||||
//Get the roles the user has from the user_roles table and check against the gate we are creating
|
|
||||||
$check = UserRole::where('character_id', auth()->user()->character_id)->get(['role']);
|
$check = UserPermission::where('character_id', auth()->user()->character_id)->get(['role']);
|
||||||
if($check[0]->role === 'None') {
|
if($check[0]-> role === 'role.none') {
|
||||||
//User has no role
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class DropUsersRoleColumn extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
if(Schema::hasColumn('users', 'role')) {
|
||||||
|
Schema::table('users', function($table) {
|
||||||
|
$table->dropColumn('role');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateAllowedLoginsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
if(!Schema::hasTable('allowed_logins')) {
|
||||||
|
Schema::create('allowed_logins', function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->string('entity_id');
|
||||||
|
$table->string('entity_type');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('allowed_logins');
|
||||||
|
}
|
||||||
|
}
|
||||||
5
vendor/composer/autoload_classmap.php
vendored
5
vendor/composer/autoload_classmap.php
vendored
@@ -9,8 +9,8 @@ return array(
|
|||||||
'App\\Console\\Commands\\CalculateMarketTax' => $baseDir . '/app/Console/Commands/calculatemarkettax.php',
|
'App\\Console\\Commands\\CalculateMarketTax' => $baseDir . '/app/Console/Commands/calculatemarkettax.php',
|
||||||
'App\\Console\\Commands\\CorpJournal' => $baseDir . '/app/Console/Commands/corpJournal.php',
|
'App\\Console\\Commands\\CorpJournal' => $baseDir . '/app/Console/Commands/corpJournal.php',
|
||||||
'App\\Console\\Commands\\DumpFleets' => $baseDir . '/app/Console/Commands/dumpFleets.php',
|
'App\\Console\\Commands\\DumpFleets' => $baseDir . '/app/Console/Commands/dumpFleets.php',
|
||||||
'App\\Console\\Commands\\GetCorps' => $baseDir . '/app/Console/Commands/getCorps.php',
|
'App\\Console\\Commands\\GetCorps' => $baseDir . '/app/Console/Commands/GetCorps.php',
|
||||||
'App\\Console\\Commands\\GetLogisticsContracts' => $baseDir . '/app/Console/Commands/getLogisticContracts.php',
|
'App\\Console\\Commands\\GetLogisticsContracts' => $baseDir . '/app/Console/Commands/GetLogisticContracts.php',
|
||||||
'App\\Console\\Commands\\SendMail' => $baseDir . '/app/Console/Commands/sendmail.php',
|
'App\\Console\\Commands\\SendMail' => $baseDir . '/app/Console/Commands/sendmail.php',
|
||||||
'App\\Console\\Commands\\UpdateMoonPricing' => $baseDir . '/app/Console/Commands/UpdateMoonPricing.php',
|
'App\\Console\\Commands\\UpdateMoonPricing' => $baseDir . '/app/Console/Commands/UpdateMoonPricing.php',
|
||||||
'App\\Console\\Commands\\holdingfinances' => $baseDir . '/app/Console/Commands/holdingfinances.php',
|
'App\\Console\\Commands\\holdingfinances' => $baseDir . '/app/Console/Commands/holdingfinances.php',
|
||||||
@@ -67,6 +67,7 @@ return array(
|
|||||||
'App\\Library\\SeatHelper' => $baseDir . '/app/Library/SeatHelper.php',
|
'App\\Library\\SeatHelper' => $baseDir . '/app/Library/SeatHelper.php',
|
||||||
'App\\Library\\Structures\\JumpBridgeFuel' => $baseDir . '/app/Library/Structures/JumpBridgeFuel.php',
|
'App\\Library\\Structures\\JumpBridgeFuel' => $baseDir . '/app/Library/Structures/JumpBridgeFuel.php',
|
||||||
'App\\Library\\Structures\\StructureTaxHelper' => $baseDir . '/app/Library/Structures/StructureTaxHelper.php',
|
'App\\Library\\Structures\\StructureTaxHelper' => $baseDir . '/app/Library/Structures/StructureTaxHelper.php',
|
||||||
|
'App\\Models\\Admin\\AllowedLogin' => $baseDir . '/app/Models/Admin/AllowedLogin.php',
|
||||||
'App\\Models\\Character\\CharacterToCorporation' => $baseDir . '/app/Models/Charcter/CharacterToCorporation.php',
|
'App\\Models\\Character\\CharacterToCorporation' => $baseDir . '/app/Models/Charcter/CharacterToCorporation.php',
|
||||||
'App\\Models\\Config' => $baseDir . '/app/Models/Config.php',
|
'App\\Models\\Config' => $baseDir . '/app/Models/Config.php',
|
||||||
'App\\Models\\Corporation\\AllianceCorp' => $baseDir . '/app/Models/Corporation/AllianceCorp.php',
|
'App\\Models\\Corporation\\AllianceCorp' => $baseDir . '/app/Models/Corporation/AllianceCorp.php',
|
||||||
|
|||||||
5
vendor/composer/autoload_static.php
vendored
5
vendor/composer/autoload_static.php
vendored
@@ -463,8 +463,8 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
|
|||||||
'App\\Console\\Commands\\CalculateMarketTax' => __DIR__ . '/../..' . '/app/Console/Commands/calculatemarkettax.php',
|
'App\\Console\\Commands\\CalculateMarketTax' => __DIR__ . '/../..' . '/app/Console/Commands/calculatemarkettax.php',
|
||||||
'App\\Console\\Commands\\CorpJournal' => __DIR__ . '/../..' . '/app/Console/Commands/corpJournal.php',
|
'App\\Console\\Commands\\CorpJournal' => __DIR__ . '/../..' . '/app/Console/Commands/corpJournal.php',
|
||||||
'App\\Console\\Commands\\DumpFleets' => __DIR__ . '/../..' . '/app/Console/Commands/dumpFleets.php',
|
'App\\Console\\Commands\\DumpFleets' => __DIR__ . '/../..' . '/app/Console/Commands/dumpFleets.php',
|
||||||
'App\\Console\\Commands\\GetCorps' => __DIR__ . '/../..' . '/app/Console/Commands/getCorps.php',
|
'App\\Console\\Commands\\GetCorps' => __DIR__ . '/../..' . '/app/Console/Commands/GetCorps.php',
|
||||||
'App\\Console\\Commands\\GetLogisticsContracts' => __DIR__ . '/../..' . '/app/Console/Commands/getLogisticContracts.php',
|
'App\\Console\\Commands\\GetLogisticsContracts' => __DIR__ . '/../..' . '/app/Console/Commands/GetLogisticContracts.php',
|
||||||
'App\\Console\\Commands\\SendMail' => __DIR__ . '/../..' . '/app/Console/Commands/sendmail.php',
|
'App\\Console\\Commands\\SendMail' => __DIR__ . '/../..' . '/app/Console/Commands/sendmail.php',
|
||||||
'App\\Console\\Commands\\UpdateMoonPricing' => __DIR__ . '/../..' . '/app/Console/Commands/UpdateMoonPricing.php',
|
'App\\Console\\Commands\\UpdateMoonPricing' => __DIR__ . '/../..' . '/app/Console/Commands/UpdateMoonPricing.php',
|
||||||
'App\\Console\\Commands\\holdingfinances' => __DIR__ . '/../..' . '/app/Console/Commands/holdingfinances.php',
|
'App\\Console\\Commands\\holdingfinances' => __DIR__ . '/../..' . '/app/Console/Commands/holdingfinances.php',
|
||||||
@@ -521,6 +521,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
|
|||||||
'App\\Library\\SeatHelper' => __DIR__ . '/../..' . '/app/Library/SeatHelper.php',
|
'App\\Library\\SeatHelper' => __DIR__ . '/../..' . '/app/Library/SeatHelper.php',
|
||||||
'App\\Library\\Structures\\JumpBridgeFuel' => __DIR__ . '/../..' . '/app/Library/Structures/JumpBridgeFuel.php',
|
'App\\Library\\Structures\\JumpBridgeFuel' => __DIR__ . '/../..' . '/app/Library/Structures/JumpBridgeFuel.php',
|
||||||
'App\\Library\\Structures\\StructureTaxHelper' => __DIR__ . '/../..' . '/app/Library/Structures/StructureTaxHelper.php',
|
'App\\Library\\Structures\\StructureTaxHelper' => __DIR__ . '/../..' . '/app/Library/Structures/StructureTaxHelper.php',
|
||||||
|
'App\\Models\\Admin\\AllowedLogin' => __DIR__ . '/../..' . '/app/Models/Admin/AllowedLogin.php',
|
||||||
'App\\Models\\Character\\CharacterToCorporation' => __DIR__ . '/../..' . '/app/Models/Charcter/CharacterToCorporation.php',
|
'App\\Models\\Character\\CharacterToCorporation' => __DIR__ . '/../..' . '/app/Models/Charcter/CharacterToCorporation.php',
|
||||||
'App\\Models\\Config' => __DIR__ . '/../..' . '/app/Models/Config.php',
|
'App\\Models\\Config' => __DIR__ . '/../..' . '/app/Models/Config.php',
|
||||||
'App\\Models\\Corporation\\AllianceCorp' => __DIR__ . '/../..' . '/app/Models/Corporation/AllianceCorp.php',
|
'App\\Models\\Corporation\\AllianceCorp' => __DIR__ . '/../..' . '/app/Models/Corporation/AllianceCorp.php',
|
||||||
|
|||||||
Reference in New Issue
Block a user