Skip to content

Commit

Permalink
Dedicated method for password validation rules.
Browse files Browse the repository at this point in the history
Puts validation rules in a dedicated method so they can be overridden
in the ResetPasswordsController in the application without needing to
override the entire reset method.  Ensures the framework response logic
in the resets method isn’t being unnecessarily overridden in an
application controller.
  • Loading branch information
danielbaylis committed Oct 23, 2016
1 parent b9f0561 commit d50c0ef
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/Illuminate/Foundation/Auth/ResetsPasswords.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ public function showResetForm(Request $request, $token = null)
*/
public function reset(Request $request)
{
$this->validate($request, [
'token' => 'required', 'email' => 'required|email',
'password' => 'required|confirmed|min:6',
]);
$this->validate($request, $this->getResetValidationRules());

// Here we will attempt to reset the user's password. If it is successful we
// will update the password on an actual user model and persist it to the
Expand All @@ -57,6 +54,19 @@ public function reset(Request $request)
: $this->sendResetFailedResponse($request, $response);
}

/**
* Get the password reset validation rules.
*
* @return array
*/
protected function getResetValidationRules()
{
return [
'token' => 'required', 'email' => 'required|email',
'password' => 'required|confirmed|min:6',
];
}

/**
* Get the password reset credentials from the request.
*
Expand Down

0 comments on commit d50c0ef

Please sign in to comment.