stuff after login

This commit is contained in:
2019-10-12 19:23:52 -05:00
parent a232b45962
commit 1a34782c35
6 changed files with 52 additions and 4 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Dashboard;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
//Library
use App\Library\Contracts\ContractHelper;

View File

@@ -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');
}

View File

@@ -15,9 +15,7 @@ class Authenticate extends Middleware
protected function redirectTo($request)
{
if($this->auth->check()) {
return route('/');
} else {
return route('/');
return route('/dashboard');
}
}
}

44
app/Traits/EveOAuth.php Normal file
View File

@@ -0,0 +1,44 @@
<?php
namespace App\Traits;
use Exception;
use GuzzleHttp\Client;
use Laravel\Socialite\Facades\Socialite;
use Laravel\Socialite\Two\InvalidStateException;
trait EveOAuth {
protected $user;
public function login() {
try {
return Socialite::driver('eveonline')->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());
}
}
?>

View File

@@ -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();
});

View File

@@ -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');
});