|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: Claudio Cardinale <[email protected]> |
|
5
|
|
|
* Date: 24/12/15 |
|
6
|
|
|
* Time: 22.53 |
|
7
|
|
|
* This program is free software; you can redistribute it and/or |
|
8
|
|
|
* modify it under the terms of the GNU General Public License |
|
9
|
|
|
* as published by the Free Software Foundation; either version 2 |
|
10
|
|
|
* of the License, or (at your option) any later version. |
|
11
|
|
|
* This program is distributed in the hope that it will be useful, |
|
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14
|
|
|
* GNU General Public License for more details. |
|
15
|
|
|
* You should have received a copy of the GNU General Public License |
|
16
|
|
|
* along with this program; if not, write to the Free Software |
|
17
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace plunner\Http\Middleware; |
|
21
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
class GetUserAndRefresh extends \Tymon\JWTAuth\Middleware\GetUserAndRefresh |
|
24
|
|
|
{ |
|
25
|
86 |
|
public function handle($request, \Closure $next, $custom = '') |
|
26
|
|
|
{ |
|
27
|
86 |
|
$remember = false; |
|
28
|
86 |
|
if($this->auth->setRequest($request)->getToken() && ($remember = $this->auth->getPayload()->get('remember')) && |
|
29
|
86 |
|
$remember == 'true'){ |
|
30
|
|
|
config(['jwt.ttl' =>'43200']); //30 days |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
//this to add the remember me mode field in the new token, but we have the custom check that is an useless |
|
34
|
|
|
//overhead |
|
35
|
86 |
|
$custom = $custom.';remember-'.$remember?'true':'false'; |
|
36
|
86 |
|
return parent::handle($request, $next, $custom); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
} |