Skip to content

Commit

Permalink
Add upgrade guide for version 2.X.X
Browse files Browse the repository at this point in the history
  • Loading branch information
bramr94 committed Apr 10, 2024
1 parent ac3302a commit ad19973
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,101 @@
# Upgrade Guide
## `1.x.x` to `2.x.x`

For version 2 we refactored most of the plugin to be more consistent with the Filament naming conventions. We've also moved some of the callbacks to the plugin, so they are configurable per panel.

### Method names

Every method name has been changed to be more consisten with the Filament naming conventions. The following changes have been made:

- `setProviders` -> `providers`
- `setSlug` -> `slug`
- `setLoginRouteName` -> `loginRouteName`
- `setDashboardRouteName` -> `dashboardRouteName`
- `setRememberLogin` -> `rememberLogin`
- `setRegistrationEnabled` -> `registration`
- `getRegistrationEnabled` -> `getRegistration`
- `setDomainAllowList` -> `domainAllowList`
- `setSocialiteUserModelClass` -> `socialiteUserModelClass
- `setUserModelClass` -> `userModelClass`
- `setShowDivider` -> `showDivider`

### Callbacks

**setCreateUserCallback**

The `setCreateUserCallback` has been renamed to `createUserUsing`. This function was first registered in the `boot` method of your `AppServiceProvider.php`, but now it should be called on the plugin.

```php
FilamentSocialitePlugin::make()
// ...
->createUserUsing(function (string $provider, SocialiteUserContract $oauthUser, FilamentSocialitePlugin $plugin) {
// Logic to create a new user.
})
```

**setUserResolver**

The `setUserResolver` has been renamed to `resolveUserUsing`. This function was first registered in the `boot` method of your `AppServiceProvider.php`, but now it should be called on the plugin.

```php
FilamentSocialitePlugin::make()
// ...
->resolveUserUsing(function (string $provider, SocialiteUserContract $oauthUser, FilamentSocialitePlugin $plugin) {
// Logic to retrieve an existing user.
})
```

**setLoginRedirectCallback**

The `setLoginRedirectCallback` has been renamed to `redirectAfterLoginUsing`. This function was first registered in the `boot` method of your `AppServiceProvider.php`, but now it should be called on the plugin.

```php
FilamentSocialitePlugin::make()
// ...
->redirectAfterLoginUsing(function (string $provider, FilamentSocialiteUserContract $socialiteUser, FilamentSocialitePlugin $plugin) {
// Change the redirect behaviour here.
})
```

### Configuration

**Optional parameters**

These where first configured in the `services.php` file, but now they should be configured in the `providers` method.

```php
FilamentSocialitePlugin::make()
->providers([
'github' => [
'label' => 'Github',
'icon' => 'fab-github',
'with' => [
// Add optional parameters here.
'hd' => 'example.com',
],
],
]),
```

**Scopes**

Scopes where first configured in the `services.php` file, but now they should be configured in the `providers` method.

```php
FilamentSocialitePlugin::make()
->providers([
'github' => [
'label' => 'Github',
'icon' => 'fab-github',
'scopes' => [
// Add scopes here.
'read:user',
'public_repo',
],
],
]),
```

## `0.x.x` to `1.x.x` (Filament v3.x)
- Replace/republish the configuration file:
- `sail artisan vendor:publish --provider="DutchCodingCompany\FilamentSocialite\FilamentSocialiteServiceProvider"`
Expand Down

0 comments on commit ad19973

Please sign in to comment.