Completed
Pull Request — master (#42)
by claudio
03:15
created

GetUserAndRefresh   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 18
ccs 6
cts 8
cp 0.75
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B handle() 0 13 5
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') &&
0 ignored issues
show
Comprehensibility introduced by
Consider adding parentheses for clarity. Current Interpretation: $remember = ($this->auth...&& $remember == 'true'), Probably Intended Meaning: ($remember = $this->auth... && $remember == 'true'
Loading history...
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
}