lopatin96 / laravel-social-auth
Laravel social auth
Installs: 5 020
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=8.0
- laravel/socialite: ^5.6
- lopatin96/laravel-lang-switcher: ^1.0
Requires (Dev)
- orchestra/testbench: ^8.0
README
Views
Add these lines to resources/views/auth/login.blade.php
:
<x-laravel-social-auth::socialite-login />
and these to resources/views/auth/register.blade.php
:
<x-laravel-social-auth::socialite-register />
FortifyServiceProvider
Add these lines to app/Providers/FortifyServiceProvider.php
as uses to manage redirections:
use Atin\LaravelSocialAuth\Http\Responses\LoginResponse; use Laravel\Fortify\Contracts\LoginResponse as LoginResponseContract; use Laravel\Fortify\Contracts\TwoFactorLoginResponse as TwoFactorLoginResponseContract;
then add singletons to boot method in app/Providers/FortifyServiceProvider.php
:
public function boot(): void { … $this->app->singleton(LoginResponseContract::class, LoginResponse::class); $this->app->singleton(TwoFactorLoginResponseContract::class, LoginResponse::class); }
Trait
Add HasSocialAccount trait to User model:
use Atin\LaravelSocialAuth\Traits\HasSocialAccount; class User extends Authenticatable { use HasSocialAccount, …
Config
Public config:
php artisan vendor:publish --tag="laravel-social-auth-config"
and comment/uncomment providers in config/laravel-social-auth.php
:
return [ 'providers' => [ 'google' => [ 'title' => 'Google', ], 'facebook' => [ 'title' => 'Facebook' ], // 'instagram' => [ // 'title' => 'Instagram' // ], ], ];
Configuration
Add these keys to config/services.php
to manage google and facebook authentications:
'google' => [ 'api_key' => env('GOOGLE_API_KEY'), 'client_id' => env('GOOGLE_CLIENT_ID'), 'client_secret' => env('GOOGLE_CLIENT_SECRET'), 'redirect' => env('GOOGLE_REDIRECT'), ], 'facebook' => [ 'client_id' => env('FACEBOOK_CLIENT_ID'), 'client_secret' => env('FACEBOOK_CLIENT_SECRET'), 'redirect' => env('FACEBOOK_REDIRECT'), ],
Publishing
Migrations
php artisan vendor:publish --tag="laravel-social-auth-migrations"
Localization
php artisan vendor:publish --tag="laravel-social-auth-lang"
Views
php artisan vendor:publish --tag="laravel-social-auth-views"
Config
php artisan vendor:publish --tag="laravel-social-auth-config"