Change login handling to automatically redirect a user if their session will need renewal.

This commit is contained in:
Dane Everitt 2018-06-16 14:05:39 -07:00
parent 24bb8da43d
commit e7faf979a1
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
8 changed files with 126 additions and 23 deletions

View file

@ -155,13 +155,15 @@ abstract class AbstractLoginController extends Controller
*/
protected function createJsonWebToken(User $user): string
{
$now = Chronos::now('utc');
$token = $this->builder
->setIssuer('Pterodactyl Panel')
->setAudience(config('app.url'))
->setId(str_random(16), true)
->setIssuedAt(Chronos::now()->getTimestamp())
->setNotBefore(Chronos::now()->getTimestamp())
->setExpiration(Chronos::now()->addSeconds(config('session.lifetime'))->getTimestamp())
->setIssuedAt($now->getTimestamp())
->setNotBefore($now->getTimestamp())
->setExpiration($now->addSeconds(config('jwt.lifetime'))->getTimestamp())
->set('user', (new AccountTransformer())->transform($user))
->sign($this->getJWTSigner(), $this->getJWTSigningKey())
->getToken();