1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use App\Models\User; |
6
|
|
|
use Carbon\Carbon; |
7
|
|
|
use Illuminate\Http\Request; |
8
|
|
|
|
9
|
|
|
class RestoreUserController extends ProfilesController |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Create a new controller instance. |
13
|
|
|
* |
14
|
|
|
* @return void |
15
|
|
|
*/ |
16
|
|
|
public function __construct() |
17
|
|
|
{ |
18
|
|
|
$this->middleware('web'); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* User Account Restore. |
23
|
|
|
* |
24
|
|
|
* @param \Illuminate\Http\Request $request |
25
|
|
|
* @param string $token |
26
|
|
|
* |
27
|
|
|
* @return \Illuminate\Http\Response |
28
|
|
|
*/ |
29
|
|
|
public function userReActivate(Request $request, $token) |
|
|
|
|
30
|
|
|
{ |
31
|
|
|
$userKeys = new ProfilesController(); |
32
|
|
|
$sepKey = $userKeys->getSeperationKey(); |
33
|
|
|
$userIdKey = $userKeys->getIdMultiKey(); |
34
|
|
|
$restoreKey = config('settings.restoreKey'); |
35
|
|
|
$encrypter = config('settings.restoreUserEncType'); |
36
|
|
|
$level5 = base64_decode($token); |
37
|
|
|
$level4 = openssl_decrypt($level5, $encrypter, $restoreKey); |
38
|
|
|
$level3 = base64_decode($level4); |
39
|
|
|
$level2 = urldecode($level3); |
40
|
|
|
$level1[] = explode($sepKey, $level2); |
|
|
|
|
41
|
|
|
$uuid = $level1[0][0]; |
|
|
|
|
42
|
|
|
$userId = $level1[0][1] / $userIdKey; |
43
|
|
|
$user = SoftDeletesController::getDeletedUser($userId); |
44
|
|
|
|
45
|
|
|
if (! is_object($user)) { |
46
|
|
|
abort(500); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$deletedDate = $user->deleted_at; |
|
|
|
|
50
|
|
|
$currentDate = Carbon::now(); |
51
|
|
|
$daysDeleted = $currentDate->diffInDays($deletedDate); |
52
|
|
|
$cutoffDays = config('settings.restoreUserCutoff'); |
53
|
|
|
|
54
|
|
|
if ($daysDeleted >= $cutoffDays) { |
55
|
|
|
return redirect('/login')->with('error', trans('profile.errorRestoreUserTime')); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$user->restore(); |
59
|
|
|
|
60
|
|
|
return redirect('/login')->with('success', trans('profile.successUserRestore', ['username' => $user->name])); |
|
|
|
|
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.