2016-09-16 06:19:40 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FireflyIII\Http\Controllers\Auth;
|
|
|
|
|
2016-09-16 09:02:35 +02:00
|
|
|
use FireflyIII\User;
|
2017-09-09 22:03:27 +02:00
|
|
|
use FireflyIII\Http\Controllers\Controller;
|
|
|
|
use Illuminate\Support\Facades\Validator;
|
2016-09-16 06:19:40 +02:00
|
|
|
use Illuminate\Foundation\Auth\RegistersUsers;
|
|
|
|
|
|
|
|
class RegisterController extends Controller
|
|
|
|
{
|
2017-09-09 22:03:27 +02:00
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Register Controller
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| This controller handles the registration of new users as well as their
|
|
|
|
| validation and creation. By default this controller uses a trait to
|
|
|
|
| provide this functionality without requiring any additional code.
|
|
|
|
|
|
|
|
|
*/
|
2016-09-16 06:19:40 +02:00
|
|
|
|
|
|
|
use RegistersUsers;
|
|
|
|
|
|
|
|
/**
|
2017-09-09 22:03:27 +02:00
|
|
|
* Where to redirect users after registration.
|
2016-09-16 06:19:40 +02:00
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $redirectTo = '/home';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new controller instance.
|
2017-09-09 22:03:27 +02:00
|
|
|
*
|
|
|
|
* @return void
|
2016-09-16 06:19:40 +02:00
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->middleware('guest');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-09-09 22:03:27 +02:00
|
|
|
* Get a validator for an incoming registration request.
|
2016-10-09 07:58:27 +02:00
|
|
|
*
|
2017-09-09 22:03:27 +02:00
|
|
|
* @param array $data
|
|
|
|
* @return \Illuminate\Contracts\Validation\Validator
|
2016-09-16 09:02:35 +02:00
|
|
|
*/
|
2017-09-09 22:03:27 +02:00
|
|
|
protected function validator(array $data)
|
2016-09-16 09:02:35 +02:00
|
|
|
{
|
2017-09-09 22:03:27 +02:00
|
|
|
return Validator::make($data, [
|
|
|
|
'email' => 'required|string|email|max:255|unique:users',
|
|
|
|
'password' => 'required|string|min:6|confirmed',
|
|
|
|
]);
|
2016-09-16 06:19:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new user instance after a valid registration.
|
|
|
|
*
|
2017-09-09 22:03:27 +02:00
|
|
|
* @param array $data
|
|
|
|
* @return \FireflyIII\User
|
2016-09-16 06:19:40 +02:00
|
|
|
*/
|
|
|
|
protected function create(array $data)
|
|
|
|
{
|
2017-09-09 22:03:27 +02:00
|
|
|
return User::create([
|
|
|
|
'email' => $data['email'],
|
|
|
|
'password' => bcrypt($data['password']),
|
|
|
|
]);
|
2016-09-16 09:02:35 +02:00
|
|
|
}
|
2016-09-16 06:19:40 +02:00
|
|
|
}
|