1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-16 16:13:20 +01:00
invoiceninja/app/Mail/Admin/VerifyUserObject.php

68 lines
2.0 KiB
PHP
Raw Normal View History

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;
2023-10-02 07:31:14 +02:00
use App\Models\Company;
use App\Models\User;
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;
2023-10-02 07:31:14 +02:00
public function __construct(public User $user, public Company $company, private bool $is_react = false)
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));
$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 = '';
2023-10-02 07:31:14 +02:00
if($this->is_react) {
2023-06-11 08:43:04 +02:00
$react_redirect = '?react=true';
2023-10-02 08:20:26 +02:00
nlog("is react");
2023-06-11 08:43:04 +02:00
}
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(),
'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';
2021-02-14 12:09:32 +01:00
return $mail_obj;
}
}