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.
composer require askedio/laravel-multiauth
Edit config/app.php
Register the provider
and alias
Askedio\MultiAuth\MultiAuthServiceProvider::class,
'MultiAuth' => Askedio\MultiAuth\Facades\MultiAuth::class,
Please note: The users
table needs some new fields & a table for the tokens.
php artisan vendor:publish
php artisan migrate
Make the Laravel auth system.
php artisan make:auth
Edit app/Http/routes.php
Add the following line.
MultiAuth::route();
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);
}
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,
],
Edit resources/views/auth/login.blade.php
Replace content with the multiauth::login
login form.
@extends('layouts.app')
@section('content')
@include('multiauth::login')
@endsection
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=