mercredi 2 octobre 2019

laravel - reset password for multiple accounts

I am using Laravel's "reset password".

There is something particular in our architecture: several accounts can have the same email address, the login is the unique key. I would like to change the password reset controller so that, in password reset view: - if the user put its email, the password is set for all accounts with this email (should I do it in a middleware? now only a random account is set, the first one I guess) - if the user put its login, we change the password of its login only

Do you think this is possible? (for new accounts it will be impossible to create a new account with an existing email, but now we have about 8000 users with double email accounts, so this cannot be changed unfortunately). thanks a lot in advance for your advices!

here is my code and I don't know where to start

class ResetPasswordController extends Controller
{
    use ResetsPasswords;

    protected $redirectTo = '/home';

    public function __construct()
    {
        $this->middleware('guest');
    }

    protected function rules()
    {
        return [
            'email' => ['required', 'string', 'email', 'max:255'],
            'password' => ['required', 'string', 'min:6', 'regex:/^(?=.*[a-z].*[a-z])(?=.*\d.*\d)(?=.*\W.*\W)[a-zA-Z0-9\S]{6,}$/'],
        ];
    }
}

class ResetPassword extends Notification
{
    use Queueable;
    public $token;
    public function __construct($token)
    {
        $this->token = $token;
    }

    public function via($notifiable)
    {
        return ['mail'];
    }

    public function toMail($notifiable)
    {
        $lang = Cookie::get('lg')!=null?Cookie::get('lg') : substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
        if($lang=='es'){
            return (new MailMessage)
                ->subject(("blabla"));
    }
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire