]> BookStack Code Mirror - bookstack/blob - app/Http/Controllers/Auth/AuthController.php
Added auth login control
[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
29
30     /**
31      * Create a new authentication controller instance.
32      *
33      * @return void
34      */
35     public function __construct()
36     {
37         $this->middleware('guest', ['except' => 'getLogout']);
38     }
39
40     /**
41      * Get a validator for an incoming registration request.
42      *
43      * @param  array  $data
44      * @return \Illuminate\Contracts\Validation\Validator
45      */
46     protected function validator(array $data)
47     {
48         return Validator::make($data, [
49             'name' => 'required|max:255',
50             'email' => 'required|email|max:255|unique:users',
51             'password' => 'required|confirmed|min:6',
52         ]);
53     }
54
55     /**
56      * Create a new user instance after a valid registration.
57      *
58      * @param  array  $data
59      * @return User
60      */
61     protected function create(array $data)
62     {
63         return User::create([
64             'name' => $data['name'],
65             'email' => $data['email'],
66             'password' => bcrypt($data['password']),
67         ]);
68     }
69 }