diff options
Diffstat (limited to 'src/controllers')
-rw-r--r-- | src/controllers/PasswordReminderController.php | 11 | ||||
-rw-r--r-- | src/controllers/UserController.php | 3 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/controllers/PasswordReminderController.php b/src/controllers/PasswordReminderController.php index 622e92c..bf9d959 100644 --- a/src/controllers/PasswordReminderController.php +++ b/src/controllers/PasswordReminderController.php @@ -9,7 +9,9 @@ namespace CamilStaps\BotleaguesApi\Controllers; use CamilStaps\BotleaguesApi\Database\PasswordReminder; +use CamilStaps\BotleaguesApi\Exception\ValidationException; use Illuminate\Support\Facades\Input; +use Illuminate\Support\Facades\Validator; class PasswordReminderController extends BaseController { @@ -23,6 +25,15 @@ class PasswordReminderController extends BaseController { * Set the userId and create a random token */ public function store() { + $rules = [ + 'user_id' => ['required'] + ]; + $payload = Input::only('user_id'); + $validator = Validator::make($payload, $rules); + if ($validator->fails()) { + throw new ValidationException('Could not find user.', $validator->errors()); + } + $this->passwordReminder->userId = Input::get('user_id'); $this->passwordReminder->token = base64_encode(openssl_random_pseudo_bytes(64)); diff --git a/src/controllers/UserController.php b/src/controllers/UserController.php index a64ed71..6af3fe8 100644 --- a/src/controllers/UserController.php +++ b/src/controllers/UserController.php @@ -2,6 +2,7 @@ namespace CamilStaps\BotleaguesApi\Controllers; use CamilStaps\BotleaguesApi\Database\User; +use CamilStaps\BotleaguesApi\Exception\ValidationException; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Input; @@ -46,7 +47,7 @@ class UserController extends BaseController { $payload = Input::only('email', 'password'); $validator = Validator::make($payload, $rules); if ($validator->fails()) { - throw new Exception\ValidationException('Could not create new user.', $validator->errors()); + throw new ValidationException('Could not create new user.', $validator->errors()); } $this->user->email = Input::get('email'); |