diff --git a/database/migrations/2024_10_27_131354_add_provider_token_columns_to_users_table.php b/database/migrations/2024_10_27_131354_add_provider_token_columns_to_users_table.php new file mode 100644 index 0000000..93f2e1f --- /dev/null +++ b/database/migrations/2024_10_27_131354_add_provider_token_columns_to_users_table.php @@ -0,0 +1,34 @@ +after('provider_name', function (Blueprint $table) { + $table->string('provider_access_token')->nullable(); + $table->string('provider_refresh_token')->nullable(); + }); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn([ + 'provider_access_token', + 'provider_refresh_token', + ]); + }); + } +}; diff --git a/src/BartenderServiceProvider.php b/src/BartenderServiceProvider.php index f02cc7c..9ee4b2a 100644 --- a/src/BartenderServiceProvider.php +++ b/src/BartenderServiceProvider.php @@ -24,6 +24,7 @@ public function boot(): void { $this->publishes([ __DIR__.'/../database/migrations/2024_03_31_000001_add_provider_columns_to_users_table.php' => database_path('migrations/2024_03_31_000001_add_provider_columns_to_users_table.php'), + __DIR__.'/../database/migrations/2024_10_27_131354_add_provider_token_columns_to_users_table.php' => database_path('migrations/2024_10_27_131354_add_provider_token_columns_to_users_table.php'), ], 'bartender-migrations'); } diff --git a/src/UserProviderRepository.php b/src/UserProviderRepository.php index 88d18e2..4fa4a2e 100644 --- a/src/UserProviderRepository.php +++ b/src/UserProviderRepository.php @@ -47,6 +47,8 @@ public function updateOrCreate(string $driver, SocialiteUser $user): Authenticat array_merge([ 'name' => $user->name, 'provider_id' => $user->id, + 'provider_access_token' => $user->token, + 'provider_refresh_token' => $user->refreshToken, 'password' => $eloquent->password ?? $this->hash($this->getNewPassword()), ], $this->isUsingSoftDeletes($model)