/** * Trigger the password reset email */ public function onRestorePassword() { $rules = ['email' => 'required|email|between:6,255']; $validation = Validator::make(post(), $rules); if ($validation->fails()) { throw new ValidationException($validation); } if (!($user = UserModel::findByEmail(post('email')))) { throw new ApplicationException(trans('rainlab.user::lang.account.invalid_user')); } $code = implode('!', [$user->id, $user->getResetPasswordCode()]); $link = $this->controller->currentPageUrl([$this->property('paramCode') => $code]); $data = ['name' => $user->name, 'link' => $link, 'code' => $code]; Mail::send('rainlab.user::mail.restore', $data, function ($message) use($user) { $message->to($user->email, $user->full_name); }); }