- Add status checker + admin secure packages + upgrade enum + add sentry + upgrade to sitemap generator + bump to CRMV2 - Set customer role enum and user role enum - Update customer migration to set roles - phpcbf - faker local to fr - update lang - composer update - bump laravel ui - Redo all user crud - npm bump - Create admin command - rearrange views - redo all auth system - redo customer pro bo
38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
|
use Illuminate\Support\Facades\Session;
|
|
|
|
class Authenticate extends Middleware
|
|
{
|
|
/**
|
|
* Get the path the user should be redirected to when they are not authenticated.
|
|
*
|
|
* @param mixed $request
|
|
* @return string|null
|
|
*/
|
|
protected function redirectTo($request)
|
|
{
|
|
$logins = [
|
|
'frontend' => route('login'),
|
|
'backend' => route('bo.login')
|
|
];
|
|
if (!$request->expectsJson()) {
|
|
// * Notify must login
|
|
Session::flash('warning', trans('Veuillez vous connecter pour continuer'));
|
|
|
|
foreach ($request->route()->gatherMiddleware() as $middleware) {
|
|
if (\is_string($middleware) and strpos($middleware, 'auth:') !== false) {
|
|
$route = $logins[str_replace('auth:', '', $middleware)] ?? null;
|
|
if ($route) {
|
|
return $route;
|
|
}
|
|
}
|
|
}
|
|
return route('login');
|
|
}
|
|
abort(401);
|
|
}
|
|
}
|