mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Refactor password reset - clientcontact
This commit is contained in:
parent
5ad5606ea2
commit
08e280e651
54
app/Mail/ClientContact/ClientContactResetPasswordObject.php
Normal file
54
app/Mail/ClientContact/ClientContactResetPasswordObject.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Mail\ClientContact;
|
||||
|
||||
class ClientContactResetPasswordObject
|
||||
{
|
||||
|
||||
public $client_contact;
|
||||
|
||||
public $token;
|
||||
|
||||
private $company;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct($token, $client_contact)
|
||||
{
|
||||
$this->token = $token;
|
||||
$this->client_contact = $client_contact;
|
||||
$this->company = $client_contact->company;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'title' => ctrans('texts.your_password_reset_link'),
|
||||
'message' => ctrans('texts.reset_password'),
|
||||
'url' => route('client.password.reset', ['token' => $this->token, 'email' => $this->client_contact->email]),
|
||||
'button' => ctrans('texts.reset'),
|
||||
'signature' => $this->company->settings->email_signature,
|
||||
'settings' => $this->company->settings,
|
||||
'logo' => $this->company->present()->logo(),
|
||||
];
|
||||
|
||||
|
||||
$mail_obj = new \stdClass;
|
||||
$mail_obj->subject = ctrans('texts.your_password_reset_link');
|
||||
$mail_obj->data = $data;
|
||||
$mail_obj->markdown = 'email.admin.generic';
|
||||
$mail_obj->tag = $this->company->company_key;
|
||||
|
||||
return $mail_obj;
|
||||
}
|
||||
}
|
@ -11,6 +11,10 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Jobs\Mail\NinjaMailer;
|
||||
use App\Jobs\Mail\NinjaMailerJob;
|
||||
use App\Jobs\Mail\NinjaMailerObject;
|
||||
use App\Mail\ClientContact\ClientContactResetPasswordObject;
|
||||
use App\Models\Presenters\ClientContactPresenter;
|
||||
use App\Notifications\ClientContactResetPassword;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
@ -151,7 +155,15 @@ class ClientContact extends Authenticatable implements HasLocalePreference
|
||||
|
||||
public function sendPasswordResetNotification($token)
|
||||
{
|
||||
$this->notify(new ClientContactResetPassword($token));
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer((new ClientContactResetPasswordObject($token, $this))->build());
|
||||
$nmo->to_user = $this;
|
||||
$nmo->company = $this->company;
|
||||
$nmo->settings = $this->company->settings;
|
||||
|
||||
NinjaMailerJob::dispatch($nmo);
|
||||
|
||||
//$this->notify(new ClientContactResetPassword($token));
|
||||
}
|
||||
|
||||
public function preferredLocale()
|
||||
|
@ -22,6 +22,7 @@ use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
//@deprecated for mail
|
||||
class ClientContactRequestCancellation extends Notification
|
||||
{
|
||||
// use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
@ -67,19 +68,6 @@ class ClientContactRequestCancellation extends Notification
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
if (static::$toMailCallback) {
|
||||
return call_user_func(static::$toMailCallback, $notifiable, $this->client_contact);
|
||||
}
|
||||
|
||||
$client_contact_name = $this->client_contact->present()->name();
|
||||
$client_name = $this->client_contact->client->present()->name();
|
||||
$recurring_invoice_number = $this->recurring_invoice->number;
|
||||
|
||||
return (new MailMessage)
|
||||
->subject('Request for recurring invoice cancellation from '.$client_contact_name)
|
||||
->markdown('email.support.cancellation', [
|
||||
'message' => "Contact [{$client_contact_name}] from Client [{$client_name}] requested to cancel Recurring Invoice [#{$recurring_invoice_number}]",
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,6 +19,7 @@ use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
//@deprecated
|
||||
class ClientContactResetPassword extends Notification
|
||||
{
|
||||
// use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
@ -55,7 +56,7 @@ class ClientContactResetPassword extends Notification
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user