Issue
by looking at ResetsPasswords code I can see that rules method is protected:
protected function rules()
{
return [
'token' => 'required',
'email' => 'required|email',
'password' => 'required|confirmed|min:6',
];
}
what is the appropriate way in laravel of adding another custom validation into the reset password form if I cant override the rules method?
I can override the reset method but its too big and if in the future versions they will change some logic I will be in trouble as I don't want to mess too much with security features
Solution
Laravel has some basic auth controllers in App\Http\Controllers\Auth;
One of them is the ResetPasswordController
controller, that is loading the trait.
In this class you can just overwrite the rules()
function.
If you don't want to update the rules()
function, you have to update the reset()
function to modify your array. But I do not suggest this, because this function is more complex and will be changed obviously than the rules()
function.
If you want to update the trait, you can extend it like this:
trait CustomResetsPasswords {
use ResetsPasswords;
public function rules() {
//return my custom rules
}
}
An then in the ResetPasswordController
you use your CustomResetsPasswords
trait.
Answered By - cre8
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.