From 085161fbc3451f90f991a0731fbaf0931cb07678 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 7 May 2015 14:16:13 +0300 Subject: Validation exception; user/login endpoint --- src/controllers/UserController.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/controllers/UserController.php') diff --git a/src/controllers/UserController.php b/src/controllers/UserController.php index e52d8c3..5c247fb 100644 --- a/src/controllers/UserController.php +++ b/src/controllers/UserController.php @@ -24,6 +24,10 @@ class UserController extends BaseController { return $this->user->findOrFail($id); } + public function login() { + return Auth::user(); + } + public function update($id) { $s = $this->user->find($id); @@ -39,14 +43,13 @@ class UserController extends BaseController { public function store() { $rules = [ - 'email' => ['required', 'email'], + 'email' => ['required', 'email', 'unique:users'], '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()); + throw new Exception\ValidationException('Could not create new user.', $validator->errors()); } $this->user->email = Input::get('email'); -- cgit v1.2.3