GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ActivateController   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 62
rs 10
c 0
b 0
f 0
wmc 8

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getAdminHomeRoute() 0 3 1
A initial() 0 16 2
A __construct() 0 3 1
A getUserHomeRoute() 0 3 1
A activeRedirect() 0 17 3
1
<?php
2
3
namespace App\Http\Controllers\Auth;
4
5
use App\Http\Controllers\Controller;
6
use App\Models\Activation;
7
use App\Models\User;
8
use App\Traits\ActivationTrait;
0 ignored issues
show
Bug introduced by
The type App\Traits\ActivationTrait was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Auth;
10
use Illuminate\Support\Facades\Log;
11
use Illuminate\Support\Facades\Route;
12
13
class ActivateController extends Controller
14
{
15
    use ActivationTrait;
16
17
    private static $userHomeRoute = 'public.home';
18
    private static $adminHomeRoute = 'public.home';
19
20
    /**
21
     * Create a new controller instance.
22
     *
23
     * @return void
24
     */
25
    public function __construct()
26
    {
27
        $this->middleware('auth');
28
    }
29
30
    public static function getUserHomeRoute()
31
    {
32
        return self::$userHomeRoute;
33
    }
34
35
    public static function getAdminHomeRoute()
36
    {
37
        return self::$adminHomeRoute;
38
    }
39
40
    public static function activeRedirect($user, $currentRoute)
41
    {
42
        if ($user->activated) {
43
            Log::info('Activated user attempted to visit '.$currentRoute.'. ', [$user]);
44
45
            if ($user->isAdmin()) {
46
                return redirect()->route(self::getAdminHomeRoute())
47
                ->with('status', 'info')
48
                ->with('message', trans('auth.alreadyActivated'));
49
            }
50
51
            return redirect()->route(self::getUserHomeRoute())
52
                ->with('status', 'info')
53
                ->with('message', trans('auth.alreadyActivated'));
54
        }
55
56
        return false;
57
    }
58
59
    public function initial()
60
    {
61
        $user = Auth::user();
62
        $lastActivation = Activation::where('user_id', $user->id)->get()->last();
0 ignored issues
show
Bug introduced by
Accessing id on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
63
        $currentRoute = Route::currentRouteName();
64
65
        $rCheck = $this->activeRedirect($user, $currentRoute);
66
        if ($rCheck) {
67
            return $rCheck;
68
        }
69
70
        $data = [
71
            'date'  => $lastActivation->created_at->format('m/d/Y'),
72
        ];
73
74
        return view($this->getActivationView())->with($data);
75
    }
76
}
77