|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* NOTICE OF LICENSE |
|
5
|
|
|
* |
|
6
|
|
|
* Part of the Rinvex Fort Package. |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to The MIT License (MIT) |
|
9
|
|
|
* that is bundled with this package in the LICENSE file. |
|
10
|
|
|
* |
|
11
|
|
|
* Package: Rinvex Fort Package |
|
12
|
|
|
* License: The MIT License (MIT) |
|
13
|
|
|
* Link: https://rinvex.com |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace Rinvex\Fort\Http\Controllers\Frontend; |
|
17
|
|
|
|
|
18
|
|
|
use Rinvex\Fort\Contracts\UserRepositoryContract; |
|
19
|
|
|
use Rinvex\Fort\Http\Controllers\AbstractController; |
|
20
|
|
|
use Rinvex\Fort\Http\Requests\Frontend\UserRegistrationRequest; |
|
21
|
|
|
|
|
22
|
|
|
class RegistrationController extends AbstractController |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* Create a new registration controller instance. |
|
26
|
|
|
*/ |
|
27
|
|
|
public function __construct() |
|
28
|
|
|
{ |
|
29
|
|
|
$this->middleware($this->getGuestMiddleware(), ['except' => $this->middlewareWhitelist]); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Show the registration form. |
|
34
|
|
|
* |
|
35
|
|
|
* @param \Rinvex\Fort\Http\Requests\Frontend\UserRegistrationRequest $request |
|
36
|
|
|
* |
|
37
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
|
|
38
|
|
|
*/ |
|
39
|
|
|
public function showRegisteration(UserRegistrationRequest $request) |
|
|
|
|
|
|
40
|
|
|
{ |
|
41
|
|
|
return view('rinvex/fort::frontend/authentication.register'); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Process the registration form. |
|
46
|
|
|
* |
|
47
|
|
|
* @param \Rinvex\Fort\Http\Requests\Frontend\UserRegistrationRequest $request |
|
48
|
|
|
* @param \Rinvex\Fort\Contracts\UserRepositoryContract $userRepository |
|
49
|
|
|
* |
|
50
|
|
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse |
|
51
|
|
|
*/ |
|
52
|
|
|
public function processRegisteration(UserRegistrationRequest $request, UserRepositoryContract $userRepository) |
|
53
|
|
|
{ |
|
54
|
|
|
// Prepare registration data |
|
55
|
|
|
$input = $request->except(['_method', '_token']); |
|
56
|
|
|
$active = ['active' => ! config('rinvex.fort.registration.moderated')]; |
|
57
|
|
|
|
|
58
|
|
|
// Fire the register start event |
|
59
|
|
|
event('rinvex.fort.register.start', [$input + $active]); |
|
60
|
|
|
|
|
61
|
|
|
$result = $userRepository->create($input + $active); |
|
62
|
|
|
|
|
63
|
|
|
// Fire the register success event |
|
64
|
|
|
event('rinvex.fort.register.success', [$result]); |
|
65
|
|
|
|
|
66
|
|
|
// Send verification if required |
|
67
|
|
|
if (config('rinvex.fort.emailverification.required')) { |
|
68
|
|
|
app('rinvex.fort.emailverification')->broker()->send(['email' => $input['email']]); |
|
69
|
|
|
|
|
70
|
|
|
// Registration completed, verification required |
|
71
|
|
|
return intend([ |
|
72
|
|
|
'intended' => url('/'), |
|
73
|
|
|
'with' => ['rinvex.fort.alert.success' => trans('rinvex/fort::frontend/messages.register.success_verify')], |
|
|
|
|
|
|
74
|
|
|
]); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
// Registration completed successfully |
|
78
|
|
|
return intend([ |
|
79
|
|
|
'intended' => route('rinvex.fort.frontend.auth.login'), |
|
80
|
|
|
'with' => ['rinvex.fort.alert.success' => trans('rinvex/fort::frontend/messages.register.success')], |
|
81
|
|
|
]); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.