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

IsWizardProfileAvailable::handle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 9
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 13
rs 9.9666
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