diff options
Diffstat (limited to 'app/Http')
-rw-r--r-- | app/Http/Controllers/Auth/RegisterController.php | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index f922f9f..2994499 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -2,11 +2,14 @@ namespace App\Http\Controllers\Auth; -use App\User; use App\Http\Controllers\Controller; +use App\Jobs\SendVerificationEmail; +use App\User; +use Illuminate\Auth\Events\Registered; +use Illuminate\Foundation\Auth\RegistersUsers; +use Illuminate\Http\Request; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; -use Illuminate\Foundation\Auth\RegistersUsers; class RegisterController extends Controller { @@ -19,7 +22,7 @@ class RegisterController extends Controller | validation and creation. By default this controller uses a trait to | provide this functionality without requiring any additional code. | - */ + */ use RegistersUsers; @@ -64,7 +67,7 @@ class RegisterController extends Controller protected function create(array $data) { $hashedPassword = Hash::make($data['password']); - $previousHash = User::select('hash')->orderBy('id','desc')->first()->hash; + $previousHash = User::select('hash')->orderBy('id', 'desc')->first()->hash; $summedHash = Hash::make($previousHash . $data['name'] . $data['email'] . 'password' . $hashedPassword); // Hash::check to verify return User::create([ @@ -72,7 +75,39 @@ class RegisterController extends Controller 'email' => $data['email'], 'password' => $hashedPassword, 'prevHash' => $previousHash, - 'hash' => $summedHash + 'hash' => $summedHash, + 'email_token' => base64_encode($data['email']), ]); } + + /** + * Handle a registration request for the application. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + + public function register(Request $request) + { + $this->validator($request->all())->validate(); + event(new Registered($user = $this->create($request->all()))); + dispatch(new SendVerificationEmail($user)); + return view('confirmEmail'); + } + + /** + * Handle a registration request for the application. + * + * @param $token + * @return \Illuminate\Http\Response + */ + public function verifyEmail($token) + { + $user = User::where('email_token', $token)->first(); + $user->verified = 1; + if ($user->save()) { + return view('verificationSuccess', ['user' => $user]); + } + } + } |