Merge pull request #6359 from turbo124/v5-develop

Client Contact password reset links
This commit is contained in:
David Bomba 2021-07-29 16:58:41 +10:00 committed by GitHub
commit 3a199abde3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 4 deletions

View File

@ -76,7 +76,6 @@ class ContactForgotPasswordController extends Controller
public function sendResetLinkEmail(ContactPasswordResetRequest $request) public function sendResetLinkEmail(ContactPasswordResetRequest $request)
{ {
$user = MultiDB::hasContact($request->input('email')); $user = MultiDB::hasContact($request->input('email'));
$this->validateEmail($request); $this->validateEmail($request);

View File

@ -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() protected function guard()
{ {
return Auth::guard('contact'); return Auth::guard('contact');

View File

@ -31,6 +31,7 @@ use App\Repositories\InvoiceRepository;
use App\Repositories\QuoteRepository; use App\Repositories\QuoteRepository;
use App\Repositories\RecurringInvoiceRepository; use App\Repositories\RecurringInvoiceRepository;
use App\Services\PdfMaker\Design as PdfMakerDesign; use App\Services\PdfMaker\Design as PdfMakerDesign;
use App\Services\PdfMaker\Design as PdfDesignModel;
use App\Services\PdfMaker\Design; use App\Services\PdfMaker\Design;
use App\Services\PdfMaker\PdfMaker; use App\Services\PdfMaker\PdfMaker;
use App\Utils\HostedPDF\NinjaPdf; use App\Utils\HostedPDF\NinjaPdf;

View File

@ -198,6 +198,10 @@ class ClientContact extends Authenticatable implements HasLocalePreference
public function sendPasswordResetNotification($token) public function sendPasswordResetNotification($token)
{ {
$this->token = $token;
$this->save();
$nmo = new NinjaMailerObject; $nmo = new NinjaMailerObject;
$nmo->mailable = new NinjaMailer((new ClientContactResetPasswordObject($token, $this))->build()); $nmo->mailable = new NinjaMailer((new ClientContactResetPasswordObject($token, $this))->build());
$nmo->to_user = $this; $nmo->to_user = $this;

View File

@ -312,7 +312,7 @@ class StripePaymentDriver extends BaseDriver
$data['name'] = $this->client->present()->name(); $data['name'] = $this->client->present()->name();
$data['phone'] = $this->client->present()->phone(); $data['phone'] = $this->client->present()->phone();
if (filter_var($this->client->present()->email(), FILTER_VALIDATE_EMAIL)) { if (filter_var($this->client->present()->email(), FILTER_VALIDATE_EMAIL)) {
$data['email'] = $this->client->present()->email(); $data['email'] = $this->client->present()->email();
} }

View File

@ -299,8 +299,8 @@ class BaseRepository
if((int)$model->balance != 0 && $model->partial > $model->amount) if((int)$model->balance != 0 && $model->partial > $model->amount)
$model->partial = min($model->amount, $model->balance); $model->partial = min($model->amount, $model->balance);
/* Update product details if necessary */ /* Update product details if necessary - if we are inside a transaction - do nothing */
if ($model->company->update_products && $model->id) if ($model->company->update_products && $model->id && \DB::transactionLevel() == 0)
UpdateOrCreateProduct::dispatch($model->line_items, $model, $model->company); UpdateOrCreateProduct::dispatch($model->line_items, $model, $model->company);
/* Perform model specific tasks */ /* Perform model specific tasks */