]> BookStack Code Mirror - bookstack/blob - app/Http/Controllers/Auth/AuthController.php
Minor fixes to editor and auth
[bookstack] / app / Http / Controllers / Auth / AuthController.php
1 <?php
2
3 namespace Oxbow\Http\Controllers\Auth;
4
5 use Oxbow\User;
6 use Validator;
7 use Oxbow\Http\Controllers\Controller;
8 use Illuminate\Foundation\Auth\ThrottlesLogins;
9 use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
10
11 class AuthController extends Controller
12 {
13     /*
14     |--------------------------------------------------------------------------
15     | Registration & Login Controller
16     |--------------------------------------------------------------------------
17     |
18     | This controller handles the registration of new users, as well as the
19     | authentication of existing users. By default, this controller uses
20     | a simple trait to add these behaviors. Why don't you explore it?
21     |
22     */
23
24     use AuthenticatesAndRegistersUsers, ThrottlesLogins;
25
26     protected $loginPath = '/login';
27     protected $redirectPath = '/';
28     protected $redirectAfterLogout = '/login';
29
30
31     /**
32      * Create a new authentication controller instance.
33      *
34      * @return void
35      */
36     public function __construct()
37     {
38         $this->middleware('guest', ['except' => 'getLogout']);
39     }
40
41     /**
42      * Get a validator for an incoming registration request.
43      *
44      * @param  array  $data
45      * @return \Illuminate\Contracts\Validation\Validator
46      */
47     protected function validator(array $data)
48     {
49         return Validator::make($data, [
50             'name' => 'required|max:255',
51             'email' => 'required|email|max:255|unique:users',
52             'password' => 'required|confirmed|min:6',
53         ]);
54     }
55
56     /**
57      * Create a new user instance after a valid registration.
58      *
59      * @param  array  $data
60      * @return User
61      */
62     protected function create(array $data)
63     {
64         return User::create([
65             'name' => $data['name'],
66             'email' => $data['email'],
67             'password' => bcrypt($data['password']),
68         ]);
69     }
70 }