askedio/laravel-multiauth

This package is abandoned and no longer maintained. No replacement package was suggested.

Authenticate using multiple sources.

v1.2 2016-05-30 01:00 UTC

This package is not auto-updated.

Last update: 2020-01-24 16:17:26 UTC


README

screen shot

Laravel Multi Auth

Authenticate your Laravel 5 applications with email/password, email link, socialite and custom drivers. Demo & Example app.

This package extends the default auth system with a custom guard, views and routes.

Installation

Install with composer.

composer require askedio/laravel-multiauth

Enable

Edit config/app.php

Register the provider and alias

 Askedio\MultiAuth\MultiAuthServiceProvider::class,
'MultiAuth' => Askedio\MultiAuth\Facades\MultiAuth::class,

Publish & migrate

Please note: The users table needs some new fields & a table for the tokens.

php artisan vendor:publish
php artisan migrate

Laravel Auth

Make the Laravel auth system.

php artisan make:auth

Configure Routes

Edit app/Http/routes.php

Add the following line.

MultiAuth::route();

Configure User Model

Edit app\User.php

Change fillable to read.

protected $fillable = [
      'name', 'email', 'password', 'avatar', 'nickname', 'confirmed',
];

Add the oauth relation.

public function oauth()
{
    return $this->hasMany(\Askedio\MultiAuth\Models\UserOauth::class);
}

Configure Auth Guards & Providers

Edit config/auth.php

Add to the guards array

'multiAuth' => [
    'driver'   => 'session',
    'provider' => 'multiAuth',
],

Add to the providers array

'multiAuth' => [
    'driver' => 'multiAuth',
    'model'  => App\User::class,
],

Configure your template

Edit resources/views/auth/login.blade.php

Replace content with the multiauth::login login form.

@extends('layouts.app')

@section('content')
  @include('multiauth::login')
@endsection

Configure Socialite

Edit config/services.php

Add all the services you want.

'facebook' => [
    'client_id'     => env('FACEBOOK_CLIENT_ID'),
    'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
    'redirect'      => env('APP_URL').'/auth/facebook/callback',
],

Edit .env and add all the settings.

FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=