Skip to content

Instantly share code, notes, and snippets.

@morrislaptop
Last active April 3, 2021 14:21
Show Gist options
  • Save morrislaptop/49fb7cdbc09110b21aa27e9976b8fc3c to your computer and use it in GitHub Desktop.
Save morrislaptop/49fb7cdbc09110b21aa27e9976b8fc3c to your computer and use it in GitHub Desktop.
<?php
Auth::viaRequest('firebase', function ($request) {
return app(FirebaseGuard::class)->user($request);
});
@usamarauf93
Copy link

can share the complete file
it is giving error

@usamarauf93
Copy link

where to add this code ?
and what to import for auth ?

@sanushen
Copy link

can share the complete file
it is giving error

`<?php

namespace App\Providers;

use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
use Auth;

class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
];

/**
 * Register any authentication / authorization services.
 *
 * @return void
 */
public function boot()
{
    $this->registerPolicies();

    Auth::viaRequest('firebase', function ($request) {
        return app(FirebaseGuard::class)->user($request);
    });
}

}
`

@morrislaptop
Copy link
Author

use Illuminate\Support\Facades\Auth;

FirebaseGuard is just a simple class you have to implement yourself. It can be DI'ed, and the user() function should accept a $request and return a Authenticable object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment