updated login controller and user model
This commit is contained in:
@@ -9,7 +9,7 @@ use DB;
|
|||||||
use Socialite;
|
use Socialite;
|
||||||
use Auth;
|
use Auth;
|
||||||
|
|
||||||
use App\User;
|
use App\Models\User\User;
|
||||||
|
|
||||||
class EsiScopeController extends Controller
|
class EsiScopeController extends Controller
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use Illuminate\Http\Request;
|
|||||||
use Socialite;
|
use Socialite;
|
||||||
use Auth;
|
use Auth;
|
||||||
|
|
||||||
use App\User;
|
use App\Models\User\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\UserPermission;
|
use App\Models\User\UserPermission;
|
||||||
@@ -93,42 +93,46 @@ class LoginController extends Controller
|
|||||||
* @param \Laravel\Socialite\Two\User $user
|
* @param \Laravel\Socialite\Two\User $user
|
||||||
*/
|
*/
|
||||||
private function createOrGetUser($eve_user) {
|
private function createOrGetUser($eve_user) {
|
||||||
//Search for user in the database
|
$authUser = null;
|
||||||
$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);
|
|
||||||
|
|
||||||
//Update the user information never the less.
|
//Search to see if we have a matching user in the database.
|
||||||
User::where('character_id', $eve_user->id)->update([
|
//At this point we don't care about the information
|
||||||
'avatar' => $eve_user->avatar,
|
$userCount = User::where('character_id', $eve_user->id)->count();
|
||||||
'owner_hash' => $eve_user->owner_hash,
|
|
||||||
'role' => $role,
|
//If the user is found, do more checks to see what type of login we are doing
|
||||||
]);
|
if($userCount > 0) {
|
||||||
//Update the user's roles and permission
|
//Search for user in the database
|
||||||
UserPermission::where(['character_id' => $eve_user->id])->delete();
|
$authUser = User::where('character_id', $eve_user->id)->first();
|
||||||
$perm = new UserPermission();
|
|
||||||
$perm->character_id = $eve_user->id;
|
//Check to see if the owner has changed
|
||||||
$perm->permission = $role;
|
//If the owner has changed, then update their roles and permissions
|
||||||
$perm->save();
|
if($this->OwnerHasChanged($authuser->owner_hash, $eve_user->owner_hash)) {
|
||||||
} else {
|
//Get the right role for the user
|
||||||
//Update the user information never the less.
|
$role = $this->GetRole(null, $eve_user->id);
|
||||||
User::where('character_id', $eve_user->id)->update([
|
//Set the role for the user
|
||||||
'avatar' => $eve_user->avatar,
|
$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.
|
//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
|
//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();
|
$tokenCount = EsiToken::where('character_id', $eve_user->id)->count();
|
||||||
if($token) {
|
if($tokenCount > 0) {
|
||||||
|
|
||||||
//Update the ESI Token
|
//Update the ESI Token
|
||||||
EsiToken::where('character_id', $eve_user->id)->update([
|
EsiToken::where('character_id', $eve_user->id)->update([
|
||||||
'character_id' => $eve_user->getId(),
|
'character_id' => $eve_user->getId(),
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use App\Library\Esi\Mail;
|
|||||||
use App\Jobs\SendEveMailJob;
|
use App\Jobs\SendEveMailJob;
|
||||||
|
|
||||||
//Models
|
//Models
|
||||||
use App\User;
|
use App\Models\User\User;
|
||||||
use App\Models\User\UserPermission;
|
use App\Models\User\UserPermission;
|
||||||
use App\Models\Contracts\Contract;
|
use App\Models\Contracts\Contract;
|
||||||
use App\Models\Contracts\Bid;
|
use App\Models\Contracts\Bid;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use App\Library\Lookups\LookupHelper;
|
|||||||
//use App\Library\Contracts\ContractHelper;
|
//use App\Library\Contracts\ContractHelper;
|
||||||
|
|
||||||
//Models
|
//Models
|
||||||
use App\User;
|
use App\Models\User\User;
|
||||||
use App\Models\User\UserPermission;
|
use App\Models\User\UserPermission;
|
||||||
use App\Models\Contracts\Contract;
|
use App\Models\Contracts\Contract;
|
||||||
use App\Models\Contracts\Bid;
|
use App\Models\Contracts\Bid;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use DB;
|
|||||||
use App\Library\Taxes\TaxesHelper;
|
use App\Library\Taxes\TaxesHelper;
|
||||||
|
|
||||||
//Models
|
//Models
|
||||||
use App\User;
|
use App\Models\User\User;
|
||||||
use App\Models\User\UserRole;
|
use App\Models\User\UserRole;
|
||||||
use App\Models\User\UserPermission;
|
use App\Models\User\UserPermission;
|
||||||
use App\Models\User\AvailableUserPermission;
|
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 Socialite;
|
||||||
use DB;
|
use DB;
|
||||||
use App\User;
|
use App\Models\User\User;
|
||||||
|
|
||||||
use Seat\Eseye\Cache\NullCache;
|
use Seat\Eseye\Cache\NullCache;
|
||||||
use Seat\Eseye\Configuration;
|
use Seat\Eseye\Configuration;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
|
|
||||||
use Socialite;
|
use Socialite;
|
||||||
use DB;
|
use DB;
|
||||||
use App\User;
|
use App\Models\User\User;
|
||||||
|
|
||||||
use Seat\Eseye\Cache\NullCache;
|
use Seat\Eseye\Cache\NullCache;
|
||||||
use Seat\Eseye\Configuration;
|
use Seat\Eseye\Configuration;
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ namespace App\Library\Taxes;
|
|||||||
use DB;
|
use DB;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
use App\User;
|
use App\Models\User\User;
|
||||||
|
|
||||||
use App\Models\User\UserRole;
|
use App\Models\User\UserRole;
|
||||||
use App\Models\User\UserPermission;
|
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' => [
|
'providers' => [
|
||||||
'users' => [
|
'users' => [
|
||||||
'driver' => 'eloquent',
|
'driver' => 'eloquent',
|
||||||
'model' => App\User::class,
|
'model' => App\Models\User\User::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
// 'users' => [
|
// 'users' => [
|
||||||
|
|||||||
@@ -295,6 +295,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<br>
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
|||||||
Reference in New Issue
Block a user