Last active
July 22, 2021 07:02
-
-
Save edgrosvenor/de3c368466ad16efb302efe1f3b10144 to your computer and use it in GitHub Desktop.
A quick and easy way to let authenticated users share the current page using a temporary signed url.
This file contains hidden or 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; | |
class SignedOrLoggedIn | |
{ | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @return mixed | |
*/ | |
public function handle(Request $request, Closure $next) | |
{ | |
if (! auth('web')->check() && ! $request->hasValidSignature(true)) { | |
abort(403); | |
} | |
return $next($request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SignedOrLoggedIn is the middleware I use to protect the routes on which I use this component.