Completed
Push — master ( c88baf...c77994 )
by claudio
08:45 queued 05:02
created

GetUserAndRefresh::handle()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 5.2743

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 15
ccs 7
cts 9
cp 0.7778
rs 8.8571
cc 5
eloc 7
nc 4
nop 3
crap 5.2743
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 285
    public function handle($request, \Closure $next, $custom = '')
26
    {
27 285
        $remember = false;
28 285
        if ($this->auth->setRequest($request)->getToken() && ($remember = $this->auth->getPayload()->get('remember')) &&
29 95
            $remember == 'true'
30 190
        ) {
31
            \JWTFactory::setTTL(43200);
32
            //config(['jwt.ttl' =>'43200']); //30 days
33
        }
34
35
        //this to add the remember me mode field in the new token, but we have the custom check that is an useless
36
        //overhead
37 285
        $custom = $custom . ';remember-' . $remember == 'true' ? 'true' : 'false';
38 285
        return parent::handle($request, $next, $custom);
39
    }
40
41
42
}