2017 © Pedro Peláez
 

project sociable

Socialite authentication and persistence layer implementation.

image

humweb/sociable

Socialite authentication and persistence layer implementation.

  • Tuesday, November 28, 2017
  • by ryun
  • Repository
  • 2 Watchers
  • 0 Stars
  • 6,401 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 15 % Grown

The README.md

Sociable

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads], (*1)

Socialite authentication and persistence layer implementation., (*2)

Install

Via Composer, (*3)

``` bash $ composer require humweb/sociable, (*4)


**Add ServiceProvider** In the `providers` array add the service providers for this package. ```php Humweb\Sociable\ServiceProvider::class ``` **Publish configuration in Laravel 5** ```bash $ php artisan vendor:publish --provider="Humweb\Sociable\ServiceProvider"

Run database migration, (*5)

$ php artisan migrate"

Configure user auth driver and provider configs, (*6)

<?php

// config/sociable.php

return [

    // Builtin options: laravel, sentinel
    'auth_provider' => 'laravel',

    // Optional provider list, mainly used to list login buttons.
    'providers' => [
        'google',
        'github',
        'twitter'
    ]
];

Add Sociable trait to user model, (*7)

class User extends Authenticatable
{
    use Sociable;
}

Getting started

See Humweb\Sociable\Http\Controllers\AuthController.php for: * OAuth login * Link third-party service to a user account, (*8)

<?php

class AuthController extends Controller
{
    /**
     * Login
     */
    public function getLogin(Request $request)
    {

        // Remove social data from session upon request
        if ($request->exists('forget_social')) {
            $request->session()->forget('social_link');
        }

        return view('login');
    }


    public function postLogin(Request $request)
    {

        // Gather credentials
        $credentials = [
            'username' => $request->get('username'),
            'password' => $request->get('password'),
        ];

        if ($user = \Auth::attempt($credentials, $remember)) {

            // Check for social data in session
            if ($request->session()->has('social_link')) {

                // Grab data from session
                $social = $request->session()->get('social_link');
                $user->attachProvider($social['provider'], $social);

                // Remove link data
                $request->session()->forget('social_link');

                return redirect()
                    ->intended('/')
                    ->with('success', 'Account connected to "'.$social['provider'].'" successfully.');
            }

            return redirect()->intended('/');
        }

        // Default error message
        return back()
            ->withInput()
            ->withErrors('Invalid login or password.');
    }

}
Example message for your login page to remove session info

This can help if the user did not want to auto link the accounts after login., (*9)

@if (session()->has('social_link'))
    <div class="alert alert-info">
        Login to link your "{{ session('social_link.provider') }}" and "<Your Site>" accounts. <br>
        If this is not what you want <a href="/login?forget_social">click here</a> to refresh.
    </div>
@endif

Change log

Please see CHANGELOG for more information what has changed recently., (*10)

Testing

bash $ phpunit, (*11)

Security

If you discover any security related issues, please email :author_email instead of using the issue tracker., (*12)

Credits

License

The MIT License (MIT). Please see License File for more information., (*13)

The Versions

28/11 2017

1.4.x-dev

1.4.9999999.9999999-dev

Socialite authentication and persistence layer implementation.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Shonfner

laravel social auth socialite

28/11 2017

1.5

1.5.0.0

Socialite authentication and persistence layer implementation.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Shonfner

laravel social auth socialite

11/03 2017

v1.4.0beta

1.4.0.0-beta

Socialite authentication and persistence layer implementation.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Shonfner

laravel social auth socialite

11/03 2017

v1.4.0

1.4.0.0

Socialite authentication and persistence layer implementation.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Shonfner

laravel social auth socialite

11/03 2017

dev-master

9999999-dev

Socialite authentication and persistence layer implementation.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Shonfner

laravel social auth socialite

11/03 2017

v1.1.0

1.1.0.0

Socialite authentication and persistence layer implementation.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Shonfner

laravel social auth socialite

10/03 2017

v1.0

1.0.0.0

Socialite authentication and persistence layer implementation.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Shonfner

laravel social auth socialite

06/08 2016

v0.3-beta

0.3.0.0-beta

Socialite authentication and persistence layer implementation.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Shonfner

laravel social auth socialite

06/08 2016

v0.2-alpha

0.2.0.0-alpha

Socialite authentication and persistence layer implementation.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Shonfner

laravel social auth socialite

05/08 2016

v0.1-alpha

0.1.0.0-alpha

Socialite authentication and persistence layer implementation.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Shonfner

laravel social auth socialite