]> git.localhorst.tv Git - alttp.git/blob - app/Http/Controllers/Auth/RegisteredUserController.php
add discord auth
[alttp.git] / app / Http / Controllers / Auth / RegisteredUserController.php
1 <?php
2
3 namespace App\Http\Controllers\Auth;
4
5 use App\Http\Controllers\Controller;
6 use App\Models\User;
7 use App\Providers\RouteServiceProvider;
8 use Illuminate\Auth\Events\Registered;
9 use Illuminate\Http\Request;
10 use Illuminate\Support\Facades\Auth;
11 use Illuminate\Support\Facades\Hash;
12 use Illuminate\Validation\Rules;
13
14 class RegisteredUserController extends Controller
15 {
16     /**
17      * Display the registration view.
18      *
19      * @return \Illuminate\View\View
20      */
21     public function create()
22     {
23         return view('auth.register');
24     }
25
26     /**
27      * Handle an incoming registration request.
28      *
29      * @param  \Illuminate\Http\Request  $request
30      * @return \Illuminate\Http\RedirectResponse
31      *
32      * @throws \Illuminate\Validation\ValidationException
33      */
34     public function store(Request $request)
35     {
36         $request->validate([
37             'name' => ['required', 'string', 'max:255'],
38             'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
39             'password' => ['required', 'confirmed', Rules\Password::defaults()],
40         ]);
41
42         $user = User::create([
43             'name' => $request->name,
44             'email' => $request->email,
45             'password' => Hash::make($request->password),
46         ]);
47
48         event(new Registered($user));
49
50         Auth::login($user);
51
52         return redirect(RouteServiceProvider::HOME);
53     }
54 }