1
0
mirror of https://github.com/flarum/core.git synced 2025-08-08 09:26:34 +02:00

Remember checkbox (#1075)

* Add session option to Rememberer class

* Update session login function to allow send additional data

* Add Remember me checkbox

* Cleanup login modal
This commit is contained in:
Sajjad Hashemian
2016-11-29 11:02:12 +03:30
committed by Toby Zerner
parent 7af4b8d45f
commit 06c32b668d
7 changed files with 77 additions and 45 deletions

View File

@@ -19,17 +19,20 @@ class Rememberer
{
protected $cookieName = 'flarum_remember';
public function remember(ResponseInterface $response, AccessToken $token)
public function remember(ResponseInterface $response, AccessToken $token, $session = false)
{
$token->lifetime = 60 * 60 * 24 * 14;
$token->save();
$cookie = $this->createCookie()->withValue($token->id);
return FigResponseCookies::set(
$response,
$this->createCookie()
->withValue($token->id)
->withMaxAge(14 * 24 * 60 * 60)
);
if (! $session) {
$lifetime = 60 * 60 * 24 * 14;
$token->lifetime = $lifetime;
$token->save();
$cookie = $cookie->withMaxAge($lifetime);
}
return FigResponseCookies::set($response, $cookie);
}
public function rememberUser(ResponseInterface $response, $userId)