1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Cortex\Auth\Http\Controllers\Tenantarea; |
6
|
|
|
|
7
|
|
|
use Cortex\Auth\Models\Member; |
8
|
|
|
use Illuminate\Auth\Events\Registered; |
9
|
|
|
use Cortex\Foundation\Http\Controllers\AbstractController; |
10
|
|
|
use Cortex\Auth\Http\Requests\Tenantarea\RegistrationRequest; |
11
|
|
|
use Cortex\Auth\Http\Requests\Tenantarea\RegistrationProcessRequest; |
12
|
|
|
|
13
|
|
|
class RegistrationController extends AbstractController |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* Create a new registration controller instance. |
17
|
|
|
*/ |
18
|
|
|
public function __construct() |
19
|
|
|
{ |
20
|
|
|
parent::__construct(); |
21
|
|
|
|
22
|
|
|
$this->middleware($this->getGuestMiddleware())->except($this->middlewareWhitelist); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Show the registration form. |
27
|
|
|
* |
28
|
|
|
* @param \Cortex\Auth\Http\Requests\Tenantarea\RegistrationRequest $request |
29
|
|
|
* |
30
|
|
|
* @return \Illuminate\View\View |
31
|
|
|
*/ |
32
|
|
|
public function form(RegistrationRequest $request) |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
return view('cortex/auth::tenantarea.pages.member-registration'); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Process the registration form. |
39
|
|
|
* |
40
|
|
|
* @param \Cortex\Auth\Http\Requests\Tenantarea\RegistrationProcessRequest $request |
41
|
|
|
* @param \Cortex\Auth\Models\Member $member |
42
|
|
|
* |
43
|
|
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse |
44
|
|
|
*/ |
45
|
|
|
public function register(RegistrationProcessRequest $request, Member $member) |
46
|
|
|
{ |
47
|
|
|
// Prepare registration data |
48
|
|
|
$data = $request->validated(); |
49
|
|
|
|
50
|
|
|
$member->fill($data)->save(); |
51
|
|
|
|
52
|
|
|
// Fire the register success event |
53
|
|
|
event(new Registered($member)); |
54
|
|
|
|
55
|
|
|
// Send verification if required |
56
|
|
|
! config('cortex.auth.emails.verification') |
57
|
|
|
|| app('rinvex.auth.emailverification')->broker($this->getEmailVerificationBroker())->sendVerificationLink(['email' => $data['email']]); |
58
|
|
|
|
59
|
|
|
// Auto-login registered member |
60
|
|
|
auth()->guard($this->getGuard())->login($member); |
|
|
|
|
61
|
|
|
|
62
|
|
|
// Registration completed successfully |
63
|
|
|
return intend([ |
64
|
|
|
'intended' => route('tenantarea.home'), |
65
|
|
|
'with' => ['success' => trans('cortex/auth::messages.register.success')], |
66
|
|
|
]); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.