This commit is contained in:
2018-11-05 19:23:38 -06:00
parent f1738ffc16
commit 16a9964092
4 changed files with 42 additions and 1 deletions

View File

@@ -113,6 +113,7 @@ class LoginController extends Controller
//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(); $token = EsiToken::where('character_id', $eve_user->id)->first();
if($token) { if($token) {
//Update the ESI Token //Update the ESI Token
DB::table('EsiTokens')->where('character_id', $eve_user->id)->update([ DB::table('EsiTokens')->where('character_id', $eve_user->id)->update([
'character_id' => $eve_user->getId(), 'character_id' => $eve_user->getId(),
@@ -122,12 +123,20 @@ class LoginController extends Controller
]); ]);
} else { } else {
//Save the ESI Token in the database //Save the ESI Token in the database
$token = new App\Models\EsiToken;
$token->character_id = $eve_user->id;
$token->access_token = $eve_user->token;
$token->refresh_token = $eve_user->refreshToken;
$token->expires_in = $eve_user->expiresIn;
$token->save();
/*
DB::table('EsiTokens')->insert([ DB::table('EsiTokens')->insert([
'character_id' => $eve_user->getId(), 'character_id' => $eve_user->getId(),
'access_token' => $eve_user->token, 'access_token' => $eve_user->token,
'refresh_token' => $eve_user->token, 'refresh_token' => $eve_user->refreshToken,
'expires_in' => $eve_user->expiresIn, 'expires_in' => $eve_user->expiresIn,
]); ]);
*/
} }
//After creating the token, we need to update the table for scopes //After creating the token, we need to update the table for scopes
//First we look for all the scopes, then if need be add entries or delete entries from the database //First we look for all the scopes, then if need be add entries or delete entries from the database

View File

@@ -15,4 +15,14 @@ class EsiScope extends Model
public function user() { public function user() {
return $this->belongsTo('App\User', 'character_id', 'character_id'); return $this->belongsTo('App\User', 'character_id', 'character_id');
} }
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'character_id',
'scope',
];
} }

View File

@@ -14,4 +14,16 @@ class EsiToken extends Model
// Timestamps // Timestamps
public $timestamps = true; public $timestamps = true;
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'character_id',
'access_token',
'refresh_token',
'expires_in',
];
} }

View File

@@ -12,6 +12,16 @@ class UserRole extends Model
// Timestamps // Timestamps
public $timestamps = true; public $timestamps = true;
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'character_id',
'role',
];
public function user() { public function user() {
return $this->belongsTo('App\User', 'character_id', 'user_id'); return $this->belongsTo('App\User', 'character_id', 'user_id');
} }