mirror of
https://github.com/flarum/framework.git
synced 2024-11-30 13:36:10 +08:00
No need to set a remember cookie if only logging in for session
This commit is contained in:
parent
659b25bbfd
commit
9a8433d02c
|
@ -81,7 +81,9 @@ class LogInController implements ControllerInterface
|
|||
|
||||
event(new UserLoggedIn($this->users->findOrFail($data->userId), $token));
|
||||
|
||||
$response = $this->rememberer->remember($response, $token, ! array_get($body, 'remember'));
|
||||
if (array_get($body, 'remember')) {
|
||||
$response = $this->rememberer->remember($response, $token);
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
|
|
@ -24,7 +24,6 @@ class Rememberer
|
|||
protected $cookie;
|
||||
|
||||
/**
|
||||
* Rememberer constructor.
|
||||
* @param CookieFactory $cookie
|
||||
*/
|
||||
public function __construct(CookieFactory $cookie)
|
||||
|
@ -32,18 +31,16 @@ class Rememberer
|
|||
$this->cookie = $cookie;
|
||||
}
|
||||
|
||||
public function remember(ResponseInterface $response, AccessToken $token, $session = false)
|
||||
public function remember(ResponseInterface $response, AccessToken $token)
|
||||
{
|
||||
$lifetime = null;
|
||||
|
||||
if (! $session) {
|
||||
$token->lifetime = $lifetime = 5 * 365 * 24 * 60 * 60; // 5 years
|
||||
$token->save();
|
||||
}
|
||||
$token->lifetime = 5 * 365 * 24 * 60 * 60; // 5 years
|
||||
$token->save();
|
||||
|
||||
return FigResponseCookies::set(
|
||||
$response,
|
||||
$this->cookie->make(self::COOKIE_NAME, $token->id, $lifetime)
|
||||
$this->cookie->make(self::COOKIE_NAME, $token->id, $token->lifetime)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user