, (*1)
Laravel Multi Auth
Authenticate your Laravel 5 applications with email/password, email link, socialite and custom drivers. Demo & Example app., (*2)
This package extends the default auth system with a custom guard, views and routes., (*3)
Installation
Install with composer.
composer require askedio/laravel-multiauth
Enable
Edit config/app.php
, (*4)
Register the provider
and alias
, (*5)
Askedio\MultiAuth\MultiAuthServiceProvider::class,
~~~
'MultiAuth' => Askedio\MultiAuth\Facades\MultiAuth::class,, (*6)
## Publish & migrate
Please note: The `users` table needs some [new fields](https://github.com/Askedio/laravel-multiauth/blob/master/database/migrations/2014_10_12_000000_add_users_table.php) & a [table](https://github.com/Askedio/laravel-multiauth/blob/master/database/migrations/2016_05_24_000000_create_user_oauth_table.php) for the tokens.
php artisan vendor:publish
php artisan migrate, (*7)
# Laravel Auth
Make the Laravel auth system.
php artisan make:auth, (*8)
## Configure Routes
Edit `app/Http/routes.php`
Add the following line.
MultiAuth::route();
~~~~, (*9)
Edit app\User.php
, (*10)
Change fillable to read., (*11)
protected $fillable = [
'name', 'email', 'password', 'avatar', 'nickname', 'confirmed',
];
Add the oauth relation., (*12)
public function oauth()
{
return $this->hasMany(\Askedio\MultiAuth\Models\UserOauth::class);
}
Edit config/auth.php
, (*13)
Add to the guards
array, (*14)
'multiAuth' => [
'driver' => 'session',
'provider' => 'multiAuth',
],
Add to the providers
array, (*15)
'multiAuth' => [
'driver' => 'multiAuth',
'model' => App\User::class,
],
Edit resources/views/auth/login.blade.php
, (*16)
Replace content with the multiauth::login
login form., (*17)
@extends('layouts.app')
@section('content')
@include('multiauth::login')
@endsection
Edit config/services.php
, (*18)
Add all the services you want., (*19)
'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., (*20)
FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=