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