updated login controller and user model
This commit is contained in:
@@ -9,7 +9,7 @@ use DB;
|
||||
use Socialite;
|
||||
use Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Models\User\User;
|
||||
|
||||
class EsiScopeController extends Controller
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ use Illuminate\Http\Request;
|
||||
use Socialite;
|
||||
use Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Models\User\User;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\User\UserPermission;
|
||||
@@ -93,42 +93,46 @@ class LoginController extends Controller
|
||||
* @param \Laravel\Socialite\Two\User $user
|
||||
*/
|
||||
private function createOrGetUser($eve_user) {
|
||||
//Search for user in the database
|
||||
$authUser = User::where('character_id', $eve_user->id)->first();
|
||||
//If the user is found, do more checks to see what type of login we are doing
|
||||
if($authUser) {
|
||||
//if a refresh token is present, then we are doing a scope callback to update scopes for an access token
|
||||
if($eve_user->refreshToken !== null) {
|
||||
//Check if the owner hash has changed to call the user type if it needs to be updated
|
||||
if($this->OwnerHasChanged($authUser->owner_hash, $eve_user->owner_hash)) {
|
||||
//Get the right role for the user
|
||||
$role = $this->GetRole(null, $eve_user->id);
|
||||
//Set the role for the user
|
||||
$this->SetRole($role, $eve_user->id);
|
||||
$authUser = null;
|
||||
|
||||
//Update the user information never the less.
|
||||
User::where('character_id', $eve_user->id)->update([
|
||||
'avatar' => $eve_user->avatar,
|
||||
'owner_hash' => $eve_user->owner_hash,
|
||||
'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 {
|
||||
//Update the user information never the less.
|
||||
User::where('character_id', $eve_user->id)->update([
|
||||
'avatar' => $eve_user->avatar,
|
||||
]);
|
||||
}
|
||||
|
||||
//Search to see if we have a matching user in the database.
|
||||
//At this point we don't care about the information
|
||||
$userCount = User::where('character_id', $eve_user->id)->count();
|
||||
|
||||
//If the user is found, do more checks to see what type of login we are doing
|
||||
if($userCount > 0) {
|
||||
//Search for user in the database
|
||||
$authUser = User::where('character_id', $eve_user->id)->first();
|
||||
|
||||
//Check to see if the owner has changed
|
||||
//If the owner has changed, then update their roles and permissions
|
||||
if($this->OwnerHasChanged($authuser->owner_hash, $eve_user->owner_hash)) {
|
||||
//Get the right role for the user
|
||||
$role = $this->GetRole(null, $eve_user->id);
|
||||
//Set the role for the user
|
||||
$this->SetRole($role, $eve_user->id);
|
||||
|
||||
//Update the user information never the less.
|
||||
User::where('character_id', $eve_user->id)->update([
|
||||
'avatar' => $eve_user->avatar,
|
||||
'owner_hash' => $eve_user->owner_hash,
|
||||
'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();
|
||||
}
|
||||
|
||||
//if a refresh token is present, then we are doing a scope callback to update scopes for an access token
|
||||
if($eve_user->refreshToken !== null) {
|
||||
//See if we have an access token for the user.
|
||||
//If we have a token update the token, if not create an entry into the database
|
||||
$token = EsiToken::where('character_id', $eve_user->id)->first();
|
||||
if($token) {
|
||||
$tokenCount = EsiToken::where('character_id', $eve_user->id)->count();
|
||||
if($tokenCount > 0) {
|
||||
|
||||
//Update the ESI Token
|
||||
EsiToken::where('character_id', $eve_user->id)->update([
|
||||
'character_id' => $eve_user->getId(),
|
||||
|
||||
@@ -14,7 +14,7 @@ use App\Library\Esi\Mail;
|
||||
use App\Jobs\SendEveMailJob;
|
||||
|
||||
//Models
|
||||
use App\User;
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\Contracts\Contract;
|
||||
use App\Models\Contracts\Bid;
|
||||
|
||||
@@ -12,7 +12,7 @@ use App\Library\Lookups\LookupHelper;
|
||||
//use App\Library\Contracts\ContractHelper;
|
||||
|
||||
//Models
|
||||
use App\User;
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\Contracts\Contract;
|
||||
use App\Models\Contracts\Bid;
|
||||
|
||||
@@ -10,7 +10,7 @@ use DB;
|
||||
use App\Library\Taxes\TaxesHelper;
|
||||
|
||||
//Models
|
||||
use App\User;
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\User\AvailableUserPermission;
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\FATs;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FatController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Srp;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SrpController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use Socialite;
|
||||
use DB;
|
||||
use App\User;
|
||||
use App\Models\User\User;
|
||||
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use Socialite;
|
||||
use DB;
|
||||
use App\User;
|
||||
use App\Models\User\User;
|
||||
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
|
||||
@@ -5,8 +5,7 @@ namespace App\Library\Taxes;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\User;
|
||||
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\User\UserPermission;
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Fleet;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Fleet extends Model
|
||||
{
|
||||
// Table Name
|
||||
protected $table = 'Fleets';
|
||||
|
||||
// Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
// Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'character_id',
|
||||
'fleet',
|
||||
'description',
|
||||
'creation_time',
|
||||
'time_left',
|
||||
];
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Fleet;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FleetActivity extends Model
|
||||
{
|
||||
// Table Name
|
||||
protected $table = 'fleet_activity_tracking';
|
||||
|
||||
// Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
// Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'fleetId',
|
||||
'character_id',
|
||||
'character_name',
|
||||
'corporation_id',
|
||||
'corporation_name',
|
||||
'region',
|
||||
'system',
|
||||
'ship',
|
||||
'ship_type',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
@@ -67,7 +67,7 @@ return [
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\User::class,
|
||||
'model' => App\Models\User\User::class,
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
|
||||
@@ -295,6 +295,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
|
||||
Reference in New Issue
Block a user