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.

RestoreUserController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
B userReActivate() 0 31 3
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Models\User;
6
use Carbon\Carbon;
7
8
class RestoreUserController extends ProfilesController
9
{
10
    /**
11
     * Create a new controller instance.
12
     *
13
     * @return void
14
     */
15
    public function __construct()
16
    {
17
        $this->middleware('web');
18
    }
19
20
    /**
21
     * User Account Restore.
22
     *
23
     * @param string $token
24
     *
25
     * @return \Illuminate\Http\Response
26
     */
27
    public function userReActivate($token)
28
    {
29
        $userKeys = new ProfilesController();
30
        $sepKey = $userKeys->getSeperationKey();
31
        $userIdKey = $userKeys->getIdMultiKey();
32
        $restoreKey = config('settings.restoreKey');
33
        $encrypter = config('settings.restoreUserEncType');
34
        $level5 = base64_decode($token);
35
        $level4 = openssl_decrypt($level5, $encrypter, $restoreKey);
36
        $level3 = base64_decode($level4);
37
        $level2 = urldecode($level3);
38
        $level1[] = explode($sepKey, $level2);
0 ignored issues
show
Comprehensibility Best Practice introduced by
$level1 was never initialized. Although not strictly required by PHP, it is generally a good practice to add $level1 = array(); before regardless.
Loading history...
39
        $userId = $level1[0][1] / $userIdKey;
40
        $user = SoftDeletesController::getDeletedUser($userId);
41
42
        if (!is_object($user)) {
43
            abort(500);
44
        }
45
46
        $deletedDate = $user->deleted_at;
0 ignored issues
show
Bug introduced by
The property deleted_at does not seem to exist on Illuminate\Http\Response.
Loading history...
47
        $currentDate = Carbon::now();
48
        $daysDeleted = $currentDate->diffInDays($deletedDate);
49
        $cutoffDays = config('settings.restoreUserCutoff');
50
51
        if ($daysDeleted >= $cutoffDays) {
52
            return redirect('/login')->with('error', trans('profile.errorRestoreUserTime'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect('/login'...errorRestoreUserTime')) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
53
        }
54
55
        $user->restore();
56
57
        return redirect('/login')->with('success', trans('profile.successUserRestore', ['username' => $user->name]));
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect('/login'...name' => $user->name))) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
Bug introduced by
The property name does not seem to exist on Illuminate\Http\Response.
Loading history...
58
    }
59
}
60