Projekt

Obecné

Profil

Stáhnout (2.28 KB) Statistiky
| Větev: | Tag: | Revize:
1
<?php
2

    
3
namespace App\Http\Controllers\Auth;
4

    
5
use App\Http\Controllers\Controller;
6
use App\Mail\RegisterMail;
7
use App\Providers\RouteServiceProvider;
8
use App\User;
9
use Illuminate\Foundation\Auth\RegistersUsers;
10
use Illuminate\Support\Facades\Hash;
11
use Illuminate\Support\Facades\Mail;
12
use Illuminate\Support\Facades\Validator;
13

    
14
class RegisterController extends Controller
15
{
16
    /*
17
    |--------------------------------------------------------------------------
18
    | Register Controller
19
    |--------------------------------------------------------------------------
20
    |
21
    | This controller handles the registration of new users as well as their
22
    | validation and creation. By default this controller uses a trait to
23
    | provide this functionality without requiring any additional code.
24
    |
25
    */
26

    
27
    use RegistersUsers;
28

    
29
    /**
30
     * Where to redirect users after registration.
31
     *
32
     * @var string
33
     */
34
    protected $redirectTo = RouteServiceProvider::HOME;
35

    
36
    /**
37
     * Create a new controller instance.
38
     *
39
     * @return void
40
     */
41
    public function __construct()
42
    {
43
        $this->middleware('guest');
44
    }
45

    
46
    /**
47
     * Get a validator for an incoming registration request.
48
     *
49
     * @param  array  $data
50
     * @return \Illuminate\Contracts\Validation\Validator
51
     */
52
    protected function validator(array $data)
53
    {
54
        return Validator::make($data, [
55
            'name' => ['required', 'string', 'max:255'],
56
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
57
            'password' => ['required', 'string', 'min:8', 'confirmed'],
58
        ]);
59
    }
60

    
61
    /**
62
     * Create a new user instance after a valid registration.
63
     *
64
     * @param  array  $data
65
     * @return \App\User
66
     */
67
    protected function create(array $data)
68
    {
69
        $stringH = Hash::make($data['email'] . $data['name']);
70
        $vowels = array("/", "\\");
71
        $stringHModified = str_replace($vowels, "", $stringH);
72

    
73
        Mail::to($data['email'])->send(new RegisterMail("http://localhost/verify/". $stringHModified));
74

    
75
        return User::create([
76
            'name' => $data['name'],
77
            'email' => $data['email'],
78
            'password' => Hash::make($data['password']),
79
            'register_hash' => $stringHModified,
80
        ]);
81
    }
82
}
(4-4/6)