-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backoffice] Add heartbeat ticker to extend sessions before they expi…
…re. Fixes #101
- Loading branch information
1 parent
1f7d597
commit 7f01c92
Showing
5 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This file is auto-generated during the composer install | ||
parameters: | ||
database_driver: pdo_mysql | ||
database_host: 192.168.0.184 | ||
database_port: null | ||
database_name: clastic | ||
database_user: clastic | ||
database_password: clastic | ||
mailer_transport: smtp | ||
mailer_host: 127.0.0.1 | ||
mailer_user: null | ||
mailer_password: null | ||
locale: en | ||
secret: ThisTokenIsNotSoSecretChangeIt | ||
debug_toolbar: true | ||
debug_redirects: false | ||
use_assetic_controller: true |
This file contains 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
33 changes: 33 additions & 0 deletions
33
src/Clastic/BackofficeBundle/Controller/HeartbeatController.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Clastic package. | ||
* | ||
* (c) Dries De Peuter <dries@nousefreak.be> | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace Clastic\BackofficeBundle\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
|
||
/** | ||
* HeartBeatController. | ||
* | ||
* @author Dries De Peuter <dries@nousefreak.be> | ||
*/ | ||
class HeartbeatController extends Controller | ||
{ | ||
/** | ||
* @return Response | ||
*/ | ||
public function tickAction() | ||
{ | ||
$maxlifetime = ini_get('session.gc_maxlifetime'); | ||
|
||
return new JsonResponse([ | ||
'lifetime' => $maxlifetime, | ||
]); | ||
} | ||
} |
This file contains 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
17 changes: 17 additions & 0 deletions
17
src/Clastic/BackofficeBundle/Resources/public/scripts/heartbeat.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
(function(){ | ||
var tickUrl = '/admin/_heartbeat'; | ||
|
||
$.ajax(tickUrl, { | ||
success: function (data) { | ||
setupHeartbeat(data.lifetime); | ||
} | ||
}); | ||
|
||
var setupHeartbeat = function (timeout) { | ||
window.setInterval(function() { | ||
$.ajax(tickUrl); | ||
}, timeout * 900); | ||
}; | ||
})(); |