diff options
-rw-r--r-- | src/controllers/UserController.php | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/controllers/UserController.php b/src/controllers/UserController.php index 03bebbc..e52d8c3 100644 --- a/src/controllers/UserController.php +++ b/src/controllers/UserController.php @@ -4,6 +4,7 @@ namespace CamilStaps\BotleaguesApi; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Input; +use Illuminate\Support\Facades\Validator; class UserController extends BaseController { @@ -37,6 +38,17 @@ class UserController extends BaseController { } public function store() { + $rules = [ + 'email' => ['required', 'email'], + 'password' => ['required', 'min:7'] + ]; + $payload = Input::only('email', 'password'); + $validator = Validator::make($payload, $rules); + + if ($validator->fails()) { + throw new \Dingo\Api\Exception\StoreResourceFailedException('Could not create new user.', $validator->errors()); + } + $this->user->email = Input::get('email'); $this->user->password = empty(Input::get('password')) ? null : Hash::make(Input::get('password')); |