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 Illuminate\Support\Facades\Auth; |
19
|
|
|
use Illuminate\Support\Facades\Lang; |
20
|
|
|
use Rinvex\Fort\Guards\SessionGuard; |
21
|
|
|
use Rinvex\Fort\Http\Requests\UserRegistration; |
22
|
|
|
use Rinvex\Fort\Http\Controllers\AbstractController; |
23
|
|
|
use Rinvex\Fort\Contracts\VerificationBrokerContract; |
24
|
|
|
|
25
|
|
|
class RegistrationController extends AbstractController |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* Create a new authentication controller instance. |
29
|
|
|
* |
30
|
|
|
* @return void |
|
|
|
|
31
|
|
|
*/ |
32
|
|
|
public function __construct() |
33
|
|
|
{ |
34
|
|
|
$this->middleware($this->getGuestMiddleware(), ['except' => $this->middlewareWhitelist]); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Show the registration form. |
39
|
|
|
* |
40
|
|
|
* @param \Rinvex\Fort\Http\Requests\UserRegistration $request |
41
|
|
|
* |
42
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
43
|
|
|
*/ |
44
|
|
|
public function showRegisteration(UserRegistration $request) |
|
|
|
|
45
|
|
|
{ |
46
|
|
|
return view('rinvex.fort::authentication.register'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Process the registration form. |
51
|
|
|
* |
52
|
|
|
* @param \Rinvex\Fort\Http\Requests\UserRegistration $request |
53
|
|
|
* |
54
|
|
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse |
55
|
|
|
*/ |
56
|
|
|
public function processRegisteration(UserRegistration $request) |
57
|
|
|
{ |
58
|
|
|
$result = Auth::guard($this->getGuard())->register($request->except('_token')); |
59
|
|
|
|
60
|
|
|
switch ($result) { |
61
|
|
|
|
62
|
|
|
// Registration completed, verification required |
63
|
|
|
case VerificationBrokerContract::LINK_SENT: |
64
|
|
|
return intend([ |
65
|
|
|
'home' => true, |
66
|
|
|
'with' => ['rinvex.fort.alert.success' => Lang::get('rinvex.fort::message.register.success_verify')], |
|
|
|
|
67
|
|
|
]); |
68
|
|
|
|
69
|
|
|
// Registration completed successfully |
70
|
|
|
case SessionGuard::AUTH_REGISTERED: |
71
|
|
|
default: |
72
|
|
|
return intend([ |
73
|
|
|
'route' => 'rinvex.fort.auth.login', |
74
|
|
|
'with' => ['rinvex.fort.alert.success' => Lang::get($result)], |
75
|
|
|
]); |
76
|
|
|
|
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.