Created
March 3, 2022 00:11
-
-
Save duncanmcclean/618f45c990fcfb1620da1a7f0647f784 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Http\Request; | |
use Illuminate\Support\Facades\Auth; | |
use Statamic\Facades\User; | |
class AutomaticallyLogin | |
{ | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next | |
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse | |
*/ | |
public function handle(Request $request, Closure $next) | |
{ | |
if (Auth::guest()) { | |
$user = User::findByEmail('[email protected]'); | |
Auth::login($user); | |
} | |
return $next($request); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http; | |
use Illuminate\Foundation\Http\Kernel as HttpKernel; | |
class Kernel extends HttpKernel | |
{ | |
/** | |
* The application's global HTTP middleware stack. | |
* | |
* These middleware are run during every request to your application. | |
* | |
* @var array | |
*/ | |
protected $middleware = [ | |
// ... | |
\App\Http\Middleware\AutomaticallyLogin::class, | |
]; | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment