Advertisement
Guest User

Untitled

a guest
Feb 27th, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.28 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers\Auth;
  4.  
  5. use App\User;
  6. use Validator;
  7. use App\Http\Controllers\Controller;
  8. use Illuminate\Foundation\Auth\ThrottlesLogins;
  9. use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
  10. use Illuminate\Foundation\Auth\AuthenticatesUsers;
  11. use Illuminate\Http\Request;
  12.  
  13. class AuthController extends Controller
  14. {
  15.     /*
  16.     |--------------------------------------------------------------------------
  17.     | Registration & Login Controller
  18.     |--------------------------------------------------------------------------
  19.     |
  20.     | This controller handles the registration of new users, as well as the
  21.     | authentication of existing users. By default, this controller uses
  22.     | a simple trait to add these behaviors. Why don't you explore it?
  23.     |
  24.     */
  25.  
  26. use AuthenticatesAndRegistersUsers {
  27.     getCredentials as traitGetCredentials;
  28. }
  29.  
  30.     use ThrottlesLogins;
  31.  
  32.     /**
  33.      * Where to redirect users after login / registration.
  34.      *
  35.      * @var string
  36.      */
  37.     protected $redirectTo = '/';
  38.  
  39.     /**
  40.      * Create a new authentication controller instance.
  41.      *
  42.      * @return void
  43.      */
  44.     public function __construct()
  45.     {
  46.         $this->middleware('guest', ['except' => 'logout']);
  47.     }
  48.  
  49.     /**
  50.      * Get a validator for an incoming registration request.
  51.      *
  52.      * @param  array  $data
  53.      * @return \Illuminate\Contracts\Validation\Validator
  54.      */
  55.     protected function validator(array $data)
  56.     {
  57.         return Validator::make($data, [
  58.             'name' => 'required|max:255|min:3',
  59.             'email' => 'required|email|max:255|unique:users',
  60.             'password' => 'required|confirmed|min:6',
  61.         ]);
  62.     }
  63.  
  64.     /**
  65.      * Create a new user instance after a valid registration.
  66.      *
  67.      * @param  array  $data
  68.      * @return User
  69.      */
  70.     protected function create(array $data)
  71.     {
  72.         return User::create([
  73.             'name' => $data['name'],
  74.             'email' => $data['email'],
  75.             'password' => bcrypt($data['password']),
  76.             'ip' => $_SERVER['REMOTE_ADDR'],
  77.         ]);
  78.     }
  79.  
  80. protected function getCredentials(Request $request)
  81. {
  82.     $login = $this->traitGetCredentials($request);
  83.  
  84.     return array_merge($login, ['block' => 0]);
  85. }
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement