|
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; |
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
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
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths