2021-02-14 12:09:32 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2023-01-28 23:21:40 +01:00
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
2021-02-14 12:09:32 +01:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2021-02-14 12:09:32 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Mail\Admin;
|
|
|
|
|
2021-06-29 11:46:40 +02:00
|
|
|
use App\Utils\Ninja;
|
2021-02-14 12:09:32 +01:00
|
|
|
use App\Utils\Traits\MakesHash;
|
2021-06-29 11:46:40 +02:00
|
|
|
use Illuminate\Support\Facades\App;
|
2021-02-14 12:09:32 +01:00
|
|
|
|
|
|
|
class VerifyUserObject
|
|
|
|
{
|
|
|
|
use MakesHash;
|
|
|
|
|
|
|
|
public $user;
|
|
|
|
|
|
|
|
public $company;
|
|
|
|
|
|
|
|
public function __construct($user, $company)
|
|
|
|
{
|
|
|
|
$this->user = $user;
|
2022-06-21 11:57:17 +02:00
|
|
|
$this->company = $company;
|
2021-02-14 12:09:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function build()
|
|
|
|
{
|
2021-06-29 11:46:40 +02:00
|
|
|
App::forgetInstance('translator');
|
|
|
|
/* Init a new copy of the translator*/
|
|
|
|
$t = app('translator');
|
|
|
|
/* Set the locale*/
|
|
|
|
App::setLocale($this->company->getLocale());
|
|
|
|
/* Set customized translations _NOW_ */
|
|
|
|
$t->replace(Ninja::transformTranslations($this->company->settings));
|
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
$this->user->confirmation_code = $this->createDbHash($this->company->db);
|
|
|
|
$this->user->save();
|
2021-02-14 12:09:32 +01:00
|
|
|
|
2023-06-11 08:43:04 +02:00
|
|
|
$react_redirect = '';
|
|
|
|
|
|
|
|
if(Ninja::isHosted()) {
|
|
|
|
$react_redirect = '?react=true';
|
|
|
|
}
|
|
|
|
|
2021-02-14 12:09:32 +01:00
|
|
|
$data = [
|
|
|
|
'title' => ctrans('texts.confirmation_subject'),
|
|
|
|
'message' => ctrans('texts.confirmation_message'),
|
2023-06-11 08:43:04 +02:00
|
|
|
'url' => url("/user/confirm/{$this->user->confirmation_code}".$react_redirect),
|
2021-02-14 12:09:32 +01:00
|
|
|
'button' => ctrans('texts.button_confirmation_message'),
|
|
|
|
'settings' => $this->company->settings,
|
2021-02-14 12:36:36 +01:00
|
|
|
'logo' => $this->company->present()->logo(),
|
2022-06-21 11:57:17 +02:00
|
|
|
'signature' => $this->company->settings->email_signature,
|
2021-02-14 12:09:32 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
$mail_obj = new \stdClass;
|
|
|
|
$mail_obj->subject = ctrans('texts.confirmation_subject');
|
|
|
|
$mail_obj->data = $data;
|
|
|
|
$mail_obj->markdown = 'email.admin.generic';
|
|
|
|
$mail_obj->tag = $this->company->company_key;
|
2022-03-04 01:45:19 +01:00
|
|
|
$mail_obj->text_view = 'email.admin.verify_user_text';
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2021-02-14 12:09:32 +01:00
|
|
|
return $mail_obj;
|
|
|
|
}
|
2022-06-21 11:57:17 +02:00
|
|
|
}
|