for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Providers;
use App\Facades\Session;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\ServiceProvider;
/**
* Class AuthServiceProvider
* @package App\Providers
*/
class AuthServiceProvider extends ServiceProvider
{
* Boot the authentication services for the application.
* If an User is stored in the Session recover it
* Only will recover if the Path() isn't the Authentcation Path
*
* @return void
public function boot()
$this->app['auth']->viaRequest('api', function ($request) {
return $request->path() == 'api/public/authentication/login'
? $this->auth($request) : $this->recover($request);
});
}
* Does the Authentication
* @param Request $request
* @return User|null
protected function auth(Request $request)
return Session::set('ChocolateyWEB', User::where('mail', $request->json()->get('email'))
->where('password', hash(Config::get('chocolatey.security.hash'),
$request->json()->get('password')))->first());
* Recover User Data
protected function recover(Request $request)
$request
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
return Session::get(Config::get('chocolatey.security.session')) ?? null;
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.