Passed
Push — master ( 1ffd02...b93f0b )
by Bertrand
06:21
created

IsWizardProfileAvailable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 15
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 13 3
1
<?php
2
3
4
namespace App\Http\Middleware;
5
6
7
use Illuminate\Support\Facades\Auth;
8
9
class IsWizardProfileAvailable
10
{
11
    public function handle($request, \Closure $next)
12
    {
13
        $user = Auth::user();
14
        if($user->context_id === null){
0 ignored issues
show
Bug Best Practice introduced by
The property context_id does not exist on App\User. Since you implemented __get, consider adding a @property annotation.
Loading history...
15
            return $next($request);
16
        }
17
        if(session()->has('wiki_callback')){
18
            $user->wiki_token = session()->get('wiki_token');
0 ignored issues
show
Bug Best Practice introduced by
The property wiki_token does not exist on App\User. Since you implemented __set, consider adding a @property annotation.
Loading history...
19
            $user->save();
20
            $callback = urldecode(session()->get('wiki_callback'));
21
            return redirect($callback);
22
        }
23
        return redirect(config('neayi.wiki_url'));
24
    }
25
}
26