diff --git a/app/Http/Controllers/Auth/ContactForgotPasswordController.php b/app/Http/Controllers/Auth/ContactForgotPasswordController.php index a3f515cdc2..be9e54b2a7 100644 --- a/app/Http/Controllers/Auth/ContactForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ContactForgotPasswordController.php @@ -76,7 +76,7 @@ class ContactForgotPasswordController extends Controller public function sendResetLinkEmail(ContactPasswordResetRequest $request) { - + $user = MultiDB::hasContact($request->input('email')); $this->validateEmail($request); diff --git a/app/Http/Controllers/Auth/ContactResetPasswordController.php b/app/Http/Controllers/Auth/ContactResetPasswordController.php index 7f6b0e047e..6de7c29729 100644 --- a/app/Http/Controllers/Auth/ContactResetPasswordController.php +++ b/app/Http/Controllers/Auth/ContactResetPasswordController.php @@ -71,6 +71,31 @@ class ContactResetPasswordController extends Controller ); } + public function reset(Request $request) + { + $request->validate($this->rules(), $this->validationErrorMessages()); + + // 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 + // database. Otherwise we will parse the error and return the response. + $response = $this->broker()->reset( + $this->credentials($request), function ($user, $password) { + $this->resetPassword($user, $password); + } + ); + + // Added this because it collides the session between + // client & main portal giving unlimited redirects. + auth()->logout(); + + // If the password was successfully reset, we will redirect the user back to + // the application's home authenticated view. If there is an error we can + // redirect them back to where they came from with their error message. + return $response == Password::PASSWORD_RESET + ? $this->sendResetResponse($request, $response) + : $this->sendResetFailedResponse($request, $response); + } + protected function guard() { return Auth::guard('contact'); diff --git a/app/Models/ClientContact.php b/app/Models/ClientContact.php index 1e5d1ee750..7e532178c5 100644 --- a/app/Models/ClientContact.php +++ b/app/Models/ClientContact.php @@ -198,6 +198,10 @@ class ClientContact extends Authenticatable implements HasLocalePreference public function sendPasswordResetNotification($token) { + + $this->token = $token; + $this->save(); + $nmo = new NinjaMailerObject; $nmo->mailable = new NinjaMailer((new ClientContactResetPasswordObject($token, $this))->build()); $nmo->to_user = $this; diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index 6e99060371..574153e946 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -299,8 +299,8 @@ class BaseRepository if((int)$model->balance != 0 && $model->partial > $model->amount) $model->partial = min($model->amount, $model->balance); - /* Update product details if necessary */ - if ($model->company->update_products && $model->id) + /* Update product details if necessary - if we are inside a transaction - do nothing */ + if ($model->company->update_products && $model->id && \DB::transactionLevel() == 0) UpdateOrCreateProduct::dispatch($model->line_items, $model, $model->company); /* Perform model specific tasks */