added new Socialite example to fit in with existing code.
This commit is contained in:
@@ -38,6 +38,47 @@ class LoginController extends Controller
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to provider's website
|
||||
*
|
||||
* @return param
|
||||
*/
|
||||
public function redirectToEveonline() {
|
||||
return Socialite::driver('eveonline')->scopes(['publicData'])->redirect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new controller instance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handleEveonlineCallback() {
|
||||
try {
|
||||
$user = Socialite::driver('eveonline')->user();
|
||||
$findUser = User::where('character_id', $user->character_id)->first();
|
||||
|
||||
if($findUser) {
|
||||
Auth::login($finduser);
|
||||
return redirect()->intended('home');
|
||||
} else {
|
||||
$newUser = User::updateOrCreate(['character_id' => $user->character_id], [
|
||||
'character_name' => $user->character_name,
|
||||
'character_id' => $user->character_id,
|
||||
'token' => $user->token,
|
||||
'refresh_token' => $user->refresh_token,
|
||||
'expiresIn' => $user->expiresIn,
|
||||
'user_jwt_token' => $user->user,
|
||||
]);
|
||||
|
||||
Auth::login($newUser);
|
||||
|
||||
return redirect()->intended('home');
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
dd($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the provider's website
|
||||
*
|
||||
@@ -50,7 +91,7 @@ class LoginController extends Controller
|
||||
* @return expiresIn
|
||||
* @return user (Holds jwt)
|
||||
*/
|
||||
public function redirectToProvider() {
|
||||
public function redirectToProvider_old() {
|
||||
//The default scope is public data for everyone due to OAuth2 Tokens
|
||||
//Add esi-mail.send_mail.v1 to send mails more efficiently
|
||||
$scopes = ['publicData', 'esi-mail.send_mail.v1'];
|
||||
|
||||
@@ -18,9 +18,11 @@ class User extends Authenticatable
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'character_id',
|
||||
'character_name',
|
||||
'email',
|
||||
'password',
|
||||
'character_owner_hash',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,5 +28,8 @@ class AppServiceProvider extends ServiceProvider
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
Event::listen(function (\SocialiteProvider\Manager\SocialiteWasCalled $event) {
|
||||
$event->extendSocialite('eveonline', \SocialiteProviders\Eveonline\Provider::class);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/horizon": "^5.44",
|
||||
"laravel/tinker": "^2.10.1",
|
||||
"laravel/ui": "^4.6",
|
||||
"socialiteproviders/eveonline": "^4.4"
|
||||
},
|
||||
"require-dev": {
|
||||
|
||||
65
composer.lock
generated
65
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "9abf5d0f046d00e112328cc59a6ee96c",
|
||||
"content-hash": "b238498d72621c2daf8235938fd6d8c3",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brick/math",
|
||||
@@ -1674,6 +1674,69 @@
|
||||
},
|
||||
"time": "2026-02-06T14:12:35+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/ui",
|
||||
"version": "v4.6.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/ui.git",
|
||||
"reference": "7d6ffa38d79f19c9b3e70a751a9af845e8f41d88"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/ui/zipball/7d6ffa38d79f19c9b3e70a751a9af845e8f41d88",
|
||||
"reference": "7d6ffa38d79f19c9b3e70a751a9af845e8f41d88",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/console": "^9.21|^10.0|^11.0|^12.0",
|
||||
"illuminate/filesystem": "^9.21|^10.0|^11.0|^12.0",
|
||||
"illuminate/support": "^9.21|^10.0|^11.0|^12.0",
|
||||
"illuminate/validation": "^9.21|^10.0|^11.0|^12.0",
|
||||
"php": "^8.0",
|
||||
"symfony/console": "^6.0|^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"orchestra/testbench": "^7.35|^8.15|^9.0|^10.0",
|
||||
"phpunit/phpunit": "^9.3|^10.4|^11.5"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Laravel\\Ui\\UiServiceProvider"
|
||||
]
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-master": "4.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Laravel\\Ui\\": "src/",
|
||||
"Illuminate\\Foundation\\Auth\\": "auth-backend/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylor@laravel.com"
|
||||
}
|
||||
],
|
||||
"description": "Laravel UI utilities and presets.",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"ui"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/laravel/ui/tree/v4.6.1"
|
||||
},
|
||||
"time": "2025-01-28T15:15:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/commonmark",
|
||||
"version": "2.8.0",
|
||||
|
||||
@@ -11,30 +11,61 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
if(!Schema::hasTable('users')) {
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('character_id');
|
||||
$table->string('character_name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->string('character_owner_hash');
|
||||
$table->string('token');
|
||||
$table->string('refresh_token');
|
||||
$table->integer('expiresIn');
|
||||
$table->string('user_jwt_token');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
if(!Schema::hasTable('password_reset_tokens')) {
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
if(!Schema::hasTable('sessions')) {
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('esi_token')) {
|
||||
Schema::create('esi_token', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('character_id');
|
||||
$table->string('token');
|
||||
$table->string('refresh_token');
|
||||
$table->integer('expiresIn');
|
||||
$table->string('user_jwt_token');
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('esi_scopes')) {
|
||||
Schema::create('esi_scopes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('character_id');
|
||||
$table->string('scope');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,5 +76,7 @@ return new class extends Migration
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
Schema::dropIfExists('esi_token');
|
||||
Schema::dropIfExists('esi_scopes');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,6 +2,19 @@
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
use App\Http\Controllers\Auth\LoginController;
|
||||
use App\Http\Controllers\Dashboard\DashboardController;
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
});
|
||||
|
||||
Auth::routes();
|
||||
|
||||
Route::get('/home', [App\Http\Controllers\DashboardController::class, 'index'])->name('dashboard');
|
||||
|
||||
Route::controller(LoginController::class)->group(function(){
|
||||
Route::get('auth/eveonline', 'redirectToEve')->('auth.eveonline');
|
||||
Route::get('auth/eveonline/callback', 'handleEveonlineCallback');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user