👨‍💻
Socialstream
  • Introduction
  • ⏮️Prologue
    • Release Notes
    • Upgrade Guide
      • Upgrading to v6 from 5.x
      • Upgrading to v5 from 4.x
      • Upgrading to v4 from 3.x
      • Upgrading to v3 from 2.x
      • Upgrading to v2 from 1.x
    • Contribution Guide
  • 🔑Getting Started
    • Installation
    • Configuration
    • Customization
      • Socialite Redirect
      • Resolving Users
      • Handling Invalid State
      • Handling OAuth Errors
      • Authenticating Users
  • 🚀Features
    • Remember Session
    • Refresh Expired Tokens
    • Provider Avatars
    • Global Login
    • Register from Login
    • Missing Emails
    • Auth Existing Unlinked Users
    • Login on Registration (deprecated)
  • 🧾guides
    • Standalone Installation
    • Filament with Jetstream
    • Filament with Breeze
    • Laravel Passport
    • Socialite Providers
    • Overriding Fortify's Authentication
  • 🔗Links
    • View Code On GitHub
    • About Me
    • Contribute
    • Donate
Powered by GitBook
On this page
  • Overview
  • Changes
  • Disabling Socialstream
  • Providers
  • Remember Sessions
  • Token Column Lengths
  • Provider Avatars
  • Connected Account Policy
  • Updating Connected Accounts
  • Resolving Users from Socialite

Was this helpful?

  1. Prologue
  2. Upgrade Guide

Upgrading to v3 from 2.x

PreviousUpgrading to v4 from 3.xNextUpgrading to v2 from 1.x

Last updated 1 year ago

Was this helpful?

This upgrade guide only discusses upgrading Socialstream 3.x and assumes you are upgrading from an unaltered 2.x install. Upgrading Jetstream, Livewire, Inertia, Vue or Tailwind CSS is out of scope for this documentation. Please consult the upgrade guides for each of these packages instead.

Overview


Changes

Disabling Socialstream

Impact: Low

To disable Socialstream in v3, you will need to update your existing SocialstreamServiceProvider.php to include the following code snippet in your providers boot method:

Socialstream::enabled(fn () => false);

The function accepts a callback so if you wanted to implement more complex logic, you may do so.

Note, the callback MUST return a boolean

Providers

Impact: Low

V3 introduces a new Providers class, for defining what Socialite providers you have enabled in your config. This class is also used in the socialstream.blade.php stub and the connected-account.blade.php component stub. Please update any Socialite providers you have in your socialstream.php config file to use this class, e.g:

use \JoelButcher\Socialstream\Providers;

return [
    // ...

    'providers' => [
        Providers::google(),
        Providers::facebook(),
    ],

];

Remember Sessions

Impact: Low

V3 of Socialstream move the remember session config variable into the 'features' config array. During your upgrade, if you have previously set this config variable to true, you will need to add it to your features list.

return [
    // ...

    'features' => [
        Features::rememberSession(),
    ],

];

Token Column Lengths

Impact: Low

In version 3.x, we've fixed an issue with the length of tokens and refresh tokens being too long for the columns in the database.

To fix this yourself, you should create a new connected_accounts migration:

php artisan make:migration update_connected_accounts_token_lengths --table=connected_accounts

Once done, you should then add the following code to the up method:

$table->string('token', 1000)->change();
$table->string('refresh_token', 1000)->change();

Provider Avatars

Impact: Low

In v3, we've updated the provider avatars feature to download the avatar from the url provided by the Socialite user. If you have opted to use the providerAvatars feature in your config's features definition, you should add the SetsProfilePhotoFromUrl trait to your user model:

<?php

use JoelButcher\Socialstream\SetsProfilePhotoFromUrl;

class User extends Authenticatable
{
    // ...
    use SetsProfilePhotoFromUrl;

    // ...
}

It's worth noting that if you still to load the users profile photo from a URL, you will need to keep the getProfilePhotoUrlAttribute method override published by Socialstream, in your user model.

Connected Account Policy

Impact: Low

Updating Connected Accounts

Impact: Low

use App\Actions\Socialstream\UpdateConnectedAccount;
use JoelButcher\Socialstream\Socialstream;

// Add this to the 'boot' method.
Socialstream::updateConnectedAccountsUsing(UpdateConnectedAccount::class);

Resolving Users from Socialite

Impact: Low

To allow additional flexibility, v3 allows you to override how your app resolves users from Socialite. For example, you may wish to call the stateless method, like so:

$user = Socialite::driver('facebook')->stateless()->user();
use App\Actions\Socialstream\ResolveSocialiteUser;
use JoelButcher\Socialstream\Socialstream;

// Add this to the 'boot' method.
Socialstream::resolvesSocialiteUsersUsing(ResolveSocialiteUser::class);

V3 uses a new policy to determine whether or not a user can access certain functionality. To ensure compatibility with v3, make sure you copy the stub found to your app/Policies directory.

Socialstream v3 will now keep your connected accounts up to date whenever a user uses SSO with your application. updating a users OAuth token and refresh token on every successful login. To make sure this works for you, copy into the app/Actions/Socialstream directory. You will then need to add the following to your app\Providers\SocialstreamServiceProvider.php:

To ensure v3 compatibility, copy the ResolveSocialiteUser action stub found to your app/Actions/Socialstream directory and add the following to your app\Providers\SocialstreamServiceProvider.php:

⏮️
Changes
Disabling Socialstream
Providers
Remember Sessions
Token Column Length
Provider Avatars
Connected Account Policy
Updating Connected Accounts
Resolving Users from Socialite
here
this stub
here