aboutsummaryrefslogtreecommitdiff
path: root/src/controllers/UserController.php
diff options
context:
space:
mode:
authorCamil Staps2015-05-07 14:16:13 +0300
committerCamil Staps2015-05-07 14:16:13 +0300
commit085161fbc3451f90f991a0731fbaf0931cb07678 (patch)
tree32f13ab154a687453b35c1787dbc92ee87bd96db /src/controllers/UserController.php
parentValidate register input (diff)
Validation exception; user/login endpoint
Diffstat (limited to 'src/controllers/UserController.php')
-rw-r--r--src/controllers/UserController.php9
1 files changed, 6 insertions, 3 deletions
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');