more modifications for moons
This commit is contained in:
@@ -45,15 +45,29 @@ class LoginController extends Controller
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function logout(Request $request) {
|
||||
Auth::logout();
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the provider's website
|
||||
*
|
||||
* @return Socialite
|
||||
*/
|
||||
public function redirectToProvider() {
|
||||
return Socialite::driver('eveonline')->setScopes(['publicData'])->redirect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get token from callback
|
||||
* Redirect to the dashboard if logging in successfully.
|
||||
*/
|
||||
public function handleProviderCallback() {
|
||||
$ssoUser = Socialite::driver('eveonline')->user();
|
||||
|
||||
@@ -78,7 +92,7 @@ class LoginController extends Controller
|
||||
} else {
|
||||
//Get what type of account the user should have
|
||||
$accountType = $this->getAccountType($eve_user->refreshToken, $eve_user->getId());
|
||||
|
||||
//Create a user account
|
||||
return User::create([
|
||||
'name' => $eve_user->getName(),
|
||||
'email' => null,
|
||||
@@ -92,7 +106,15 @@ class LoginController extends Controller
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the appropriate account type the user should be assigned through ESI API
|
||||
*
|
||||
* @param refreshToken
|
||||
* @param charId
|
||||
*
|
||||
* @return text
|
||||
*/
|
||||
private function getAccountType($refreshToken, $charId) {
|
||||
//Set caching to null
|
||||
$configuration = Configuration::getInstance();
|
||||
@@ -117,7 +139,7 @@ class LoginController extends Controller
|
||||
$corp_info = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $character_info->corporation_id,
|
||||
]);
|
||||
|
||||
//Send back the appropriate group
|
||||
if($corp_info->alliance_id == '99004116') {
|
||||
return 'W4RP';
|
||||
} else if(in_array($alliance_info->alliance_id, array(99006297, 498125261, 99003214, 99004136, 9900237, 99001657, 99006069, 99001099, 99003838))) {
|
||||
|
||||
@@ -4,8 +4,6 @@ namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Library;
|
||||
//use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
//use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@@ -36,48 +34,7 @@ class DashboardController extends Controller
|
||||
}
|
||||
|
||||
public function profile() {
|
||||
/**
|
||||
* Check to see if the user has a valid esi token
|
||||
*/
|
||||
$user = Auth::user();
|
||||
//Try to find the user's ESI token.
|
||||
$token = DB::table('esitokens')->where('CharacterId', $user['character_id'])->first();
|
||||
if($token != null) {
|
||||
$html = '<h3>ESI Token Already Stored</h3>';
|
||||
} else {
|
||||
//Setup the display button if the user doesn't have an ESI registered
|
||||
$state = uniqid();
|
||||
session(['state' => $state]);
|
||||
$esiLogin = new \App\Library\EsiLogin();
|
||||
$html = $esiLogin->DisplayLoginButton($state);
|
||||
}
|
||||
|
||||
|
||||
return view('dashboard.profile')->with('html', $html);
|
||||
}
|
||||
|
||||
public function callback(Request $request) {
|
||||
$esiLogin = new \App\Library\EsiLogin();
|
||||
//Pull the old session state from the session, and delete the key
|
||||
$oldState = $request->session()->pull('state');
|
||||
//Check the state to make sure it matches
|
||||
if($oldState == $request->input('state')) {
|
||||
$esiLogin->RetrieveAccessToken();
|
||||
$esiLogin->RetrieveCharacterId();
|
||||
//Store the token in the database
|
||||
$token = new \App\EsiToken;
|
||||
$token->CharacterId = $esiLogin->GetCharacterId();
|
||||
$token->AccessToken = $esiLogin->GetAccessToken();
|
||||
$token->RefreshToken = $esiLogin->GetRefreshToken();
|
||||
$token->ExpiresIn = $esiLogin->GetRefreskTokenExpiry();
|
||||
$token->save();
|
||||
//Return view back to profile with success message
|
||||
return view('dashboard')->with('message', 'Success!');
|
||||
} else {
|
||||
//Return view with error message back to the dashboard
|
||||
return view('dashboard')->with('message', 'Error!');
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
public function displayMoons() {
|
||||
|
||||
Reference in New Issue
Block a user