|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Auth; |
|
4
|
|
|
|
|
5
|
|
|
use App\Activation; |
|
|
|
|
|
|
6
|
|
|
use App\Http\Controllers\Controller; |
|
7
|
|
|
use App\Models\User; |
|
8
|
|
|
use App\Providers\RouteServiceProvider; |
|
9
|
|
|
use Illuminate\Http\Request; |
|
10
|
|
|
use Illuminate\Support\Facades\Validator; |
|
11
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
12
|
|
|
|
|
13
|
|
|
class VerificationController extends Controller |
|
14
|
|
|
{ |
|
15
|
|
|
// use VerifiesEmails; |
|
16
|
|
|
|
|
17
|
|
|
protected $redirectTo = RouteServiceProvider::HOME; |
|
18
|
|
|
|
|
19
|
|
|
public function __construct() |
|
20
|
|
|
{ |
|
21
|
|
|
// $this->middleware('auth'); |
|
22
|
|
|
// $this->middleware('signed')->only('verify'); |
|
23
|
|
|
// $this->middleware('throttle:6,1')->only('verify', 'resend'); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* verify user token. |
|
28
|
|
|
*/ |
|
29
|
|
|
public function verify_user(Request $request) |
|
30
|
|
|
{ |
|
31
|
|
|
$token = null; |
|
|
|
|
|
|
32
|
|
|
$activation = null; |
|
|
|
|
|
|
33
|
|
|
$user_id = null; |
|
|
|
|
|
|
34
|
|
|
$user = null; |
|
|
|
|
|
|
35
|
|
|
$data = $request->all(); |
|
36
|
|
|
$this->validator($data)->validate(); |
|
37
|
|
|
$token = $request->get('token'); |
|
38
|
|
|
$activation = Activation::where('token', $token)->first(); |
|
39
|
|
|
if ($activation === null) { |
|
40
|
|
|
return response()->json( |
|
41
|
|
|
[ |
|
42
|
|
|
'error' => [ |
|
43
|
|
|
'code' => 300, |
|
44
|
|
|
'message' => 'Send activation code again.', |
|
45
|
|
|
], |
|
46
|
|
|
], |
|
47
|
|
|
Response::HTTP_UNPROCESSABLE_ENTITY |
|
48
|
|
|
); |
|
49
|
|
|
} |
|
50
|
|
|
$user_id = $activation->user_id; |
|
51
|
|
|
$user = User::find($user_id); |
|
52
|
|
|
if ($user === null) { |
|
53
|
|
|
return response()->json( |
|
54
|
|
|
[ |
|
55
|
|
|
'error' => [ |
|
56
|
|
|
'code' => 301, |
|
57
|
|
|
'message' => 'There is not such user.', |
|
58
|
|
|
], |
|
59
|
|
|
], |
|
60
|
|
|
Response::HTTP_UNPROCESSABLE_ENTITY |
|
61
|
|
|
); |
|
62
|
|
|
} |
|
63
|
|
|
$user->is_active = 1; |
|
64
|
|
|
$user->email_verified_at = date('Y-m-d H:i:s'); |
|
65
|
|
|
$user->save(); |
|
66
|
|
|
Activation::where('user_id', $user_id)->delete(); |
|
67
|
|
|
return response()->json([ |
|
68
|
|
|
'csrfToken' => csrf_token(), |
|
69
|
|
|
]); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
protected function validator(array $data) |
|
73
|
|
|
{ |
|
74
|
|
|
return Validator::make($data, [ |
|
75
|
|
|
'token' => ['required', 'string', 'max:255'], |
|
76
|
|
|
]); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
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