Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.
/ laravel-multiauth Public archive

A package to easily enable authentication with multiple sources, email/password, email link, socialite, & custom drivers.

License

Notifications You must be signed in to change notification settings

Askedio/laravel-multiauth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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=

About

A package to easily enable authentication with multiple sources, email/password, email link, socialite, & custom drivers.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages