1 |
21570473
|
Adam Mištera
|
<?php
|
2 |
|
|
|
3 |
|
|
namespace App\Http\Controllers\Auth;
|
4 |
|
|
|
5 |
|
|
use App\Http\Controllers\Controller;
|
6 |
75508baf
|
Marek Lovčí
|
use App\Mail\RegisterMail;
|
7 |
21570473
|
Adam Mištera
|
use App\Providers\RouteServiceProvider;
|
8 |
|
|
use App\User;
|
9 |
75508baf
|
Marek Lovčí
|
use Illuminate\Routing\UrlGenerator;
|
10 |
21570473
|
Adam Mištera
|
use Illuminate\Foundation\Auth\RegistersUsers;
|
11 |
|
|
use Illuminate\Support\Facades\Hash;
|
12 |
75508baf
|
Marek Lovčí
|
use Illuminate\Support\Facades\Mail;
|
13 |
21570473
|
Adam Mištera
|
use Illuminate\Support\Facades\Validator;
|
14 |
|
|
|
15 |
|
|
class RegisterController extends Controller
|
16 |
|
|
{
|
17 |
|
|
/*
|
18 |
|
|
|--------------------------------------------------------------------------
|
19 |
|
|
| Register Controller
|
20 |
|
|
|--------------------------------------------------------------------------
|
21 |
|
|
|
|
22 |
|
|
| This controller handles the registration of new users as well as their
|
23 |
|
|
| validation and creation. By default this controller uses a trait to
|
24 |
|
|
| provide this functionality without requiring any additional code.
|
25 |
|
|
|
|
26 |
|
|
*/
|
27 |
|
|
|
28 |
|
|
use RegistersUsers;
|
29 |
|
|
|
30 |
|
|
/**
|
31 |
|
|
* Where to redirect users after registration.
|
32 |
|
|
*
|
33 |
|
|
* @var string
|
34 |
|
|
*/
|
35 |
|
|
protected $redirectTo = RouteServiceProvider::HOME;
|
36 |
|
|
|
37 |
|
|
/**
|
38 |
|
|
* Create a new controller instance.
|
39 |
|
|
*
|
40 |
|
|
* @return void
|
41 |
|
|
*/
|
42 |
|
|
public function __construct()
|
43 |
|
|
{
|
44 |
|
|
$this->middleware('guest');
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
/**
|
48 |
|
|
* Get a validator for an incoming registration request.
|
49 |
|
|
*
|
50 |
|
|
* @param array $data
|
51 |
|
|
* @return \Illuminate\Contracts\Validation\Validator
|
52 |
|
|
*/
|
53 |
|
|
protected function validator(array $data)
|
54 |
|
|
{
|
55 |
|
|
return Validator::make($data, [
|
56 |
|
|
'name' => ['required', 'string', 'max:255'],
|
57 |
|
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
58 |
|
|
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
59 |
|
|
]);
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
/**
|
63 |
|
|
* Create a new user instance after a valid registration.
|
64 |
|
|
*
|
65 |
|
|
* @param array $data
|
66 |
|
|
* @return \App\User
|
67 |
|
|
*/
|
68 |
|
|
protected function create(array $data)
|
69 |
|
|
{
|
70 |
75508baf
|
Marek Lovčí
|
$stringH = Hash::make($data['email'] . $data['name']);
|
71 |
|
|
$vowels = array("/", "\\");
|
72 |
|
|
$stringHModified = str_replace($vowels, "", $stringH);
|
73 |
|
|
|
74 |
|
|
//Mail::to($data['email'])->send(new RegisterMail("http://localhost/verify/". $stringHModified));
|
75 |
|
|
Mail::to($data['email'])->send(new RegisterMail(url("/verify/") . "/" . $stringHModified));//http://localhost/register/verify/..
|
76 |
21570473
|
Adam Mištera
|
|
77 |
|
|
return User::create([
|
78 |
|
|
'name' => $data['name'],
|
79 |
|
|
'email' => $data['email'],
|
80 |
|
|
'password' => Hash::make($data['password']),
|
81 |
75508baf
|
Marek Lovčí
|
'register_hash' => $stringHModified,
|
82 |
21570473
|
Adam Mištera
|
]);
|
83 |
|
|
}
|
84 |
|
|
}
|