1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 09:34:04 +00:00

TTL argument

This commit is contained in:
Samuel Štancl 2020-06-29 12:21:02 +02:00
parent 405a137ca1
commit b362c16f89

View file

@ -32,9 +32,10 @@ class UserImpersonation implements Feature
* Impersonate a user and get an HTTP redirect response.
*
* @param string|ImpersonationToken $token
* @param int $ttl
* @return RedirectResponse
*/
public static function makeResponse($token): RedirectResponse
public static function makeResponse($token, int $ttl = null): RedirectResponse
{
$token = $token instanceof ImpersonationToken ? $token : ImpersonationToken::findOrFail($token);
@ -42,7 +43,9 @@ class UserImpersonation implements Feature
abort(403);
}
if ($token->created_at->diffInSeconds(Carbon::now()) > static::$ttl) {
$ttl = $ttl ?? static::$ttl;
if ($token->created_at->diffInSeconds(Carbon::now()) > $ttl) {
abort(403);
}