From 1a34782c3510f22225ae8099bf495dff36e25657 Mon Sep 17 00:00:00 2001 From: drkthunder02 Date: Sat, 12 Oct 2019 19:23:52 -0500 Subject: [PATCH] stuff after login --- .../Dashboard/DashboardController.php | 1 + .../Controllers/Hauling/HaulingController.php | 4 ++ app/Http/Middleware/Authenticate.php | 4 +- app/Traits/EveOAuth.php | 44 +++++++++++++++++++ .../2014_10_12_000000_create_users_table.php | 1 + routes/web.php | 2 +- 6 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 app/Traits/EveOAuth.php diff --git a/app/Http/Controllers/Dashboard/DashboardController.php b/app/Http/Controllers/Dashboard/DashboardController.php index b0a42d0..9257a04 100644 --- a/app/Http/Controllers/Dashboard/DashboardController.php +++ b/app/Http/Controllers/Dashboard/DashboardController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Dashboard; use Illuminate\Http\Request; +use App\Http\Controllers\Controller; //Library use App\Library\Contracts\ContractHelper; diff --git a/app/Http/Controllers/Hauling/HaulingController.php b/app/Http/Controllers/Hauling/HaulingController.php index 4d2fbf6..0882b90 100644 --- a/app/Http/Controllers/Hauling/HaulingController.php +++ b/app/Http/Controllers/Hauling/HaulingController.php @@ -23,6 +23,10 @@ class HaulingController extends Controller * Controller function to display form */ public function displayForm() { + if(Auth::check()) { + return redirect('/dashboard'); + } + return view('hauling.display.form'); } diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index e550d9c..d8b2160 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -15,9 +15,7 @@ class Authenticate extends Middleware protected function redirectTo($request) { if($this->auth->check()) { - return route('/'); - } else { - return route('/'); + return route('/dashboard'); } } } diff --git a/app/Traits/EveOAuth.php b/app/Traits/EveOAuth.php new file mode 100644 index 0000000..6cb28fc --- /dev/null +++ b/app/Traits/EveOAuth.php @@ -0,0 +1,44 @@ +redirect(); + } catch(Exception $e) { + return back(); + } + } + + public function callback() { + try { + $this->user = Socialite::driver('eveonline')->user(); + } catch(InvalidStateException $e) { + return back(); + } + return $this->user; + } + + public function get_character() { + //Get more detailed character data from CREST + $httpClient = new Client(); + $url = "https://esi.evetech.net/latest/characters/{$this->user->id}/?datasource=tranquility"; + try { + $response = $httpClient->get($url); + } catch (Exception $exception) { + return abort(504, 'ESI is not reachable, try again late.'); + } + return json_decode($response->getBody()->getContents()); + } +} + +?> diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 8e7ebb9..9ce053f 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -24,6 +24,7 @@ class CreateUsersTable extends Migration $table->integer('inserted_at')->default(0); $table->integer('expires_in')->default(0); $table->string('owner_hash'); + $table->string('remember_token')->nullable(); $table->string('user_type')->default('Guest'); $table->timestamps(); }); diff --git a/routes/web.php b/routes/web.php index 842bd0c..40e9d6e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -22,7 +22,7 @@ Route::group(['middleware' => ['auth']], function(){ /** * Dashboard Controller Display pages */ - Route::get('/dashboard', 'Dashboard\DashboardController@index'); + Route::get('/dashboard', 'Dashboard\DashboardController@index')->name('/dashboard'); //Route::get('/profile', 'Dashboard\DashboardController@profile'); });