mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 21:34:04 +00:00
TTL argument
This commit is contained in:
parent
405a137ca1
commit
b362c16f89
1 changed files with 5 additions and 2 deletions
|
|
@ -32,9 +32,10 @@ class UserImpersonation implements Feature
|
||||||
* Impersonate a user and get an HTTP redirect response.
|
* Impersonate a user and get an HTTP redirect response.
|
||||||
*
|
*
|
||||||
* @param string|ImpersonationToken $token
|
* @param string|ImpersonationToken $token
|
||||||
|
* @param int $ttl
|
||||||
* @return RedirectResponse
|
* @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);
|
$token = $token instanceof ImpersonationToken ? $token : ImpersonationToken::findOrFail($token);
|
||||||
|
|
||||||
|
|
@ -42,7 +43,9 @@ class UserImpersonation implements Feature
|
||||||
abort(403);
|
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);
|
abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue