1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #6112 from turbo124/v5-develop

Fixes for Two Factor
This commit is contained in:
David Bomba 2021-06-23 14:55:30 +10:00 committed by GitHub
commit d2d62adf55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 15 deletions

View File

@ -398,7 +398,6 @@ class CompanySettings extends BaseSettings
'email_template_reminder2' => 'string',
'email_template_reminder3' => 'string',
'email_template_reminder_endless' => 'string',
'enable_client_portal_password' => 'bool',
'inclusive_taxes' => 'bool',
'invoice_number_pattern' => 'string',
'invoice_number_counter' => 'integer',

View File

@ -46,8 +46,6 @@ class GmailTransport extends Transport
$this->gmail = null;
$this->gmail = new Mail;
nlog(array_keys($message->getBcc()));
/*We should nest the token in the message and then discard it as needed*/
$token = $message->getHeaders()->get('GmailToken')->getValue();
@ -67,8 +65,6 @@ class GmailTransport extends Transport
foreach ($message->getChildren() as $child)
{
nlog("trying to attach");
if($child->getContentType() != 'text/plain')
{

View File

@ -11,11 +11,16 @@
namespace App\Http\Controllers;
use PragmaRX\Google2FA\Google2FA;
use App\Models\User;
use Crypt;
use PragmaRX\Google2FA\Google2FA;
class TwoFactorController extends BaseController
{
protected $entity_type = User::class;
protected $entity_transformer = UserTransformer::class;
public function setupTwoFactor()
{
$user = auth()->user();

View File

@ -377,23 +377,28 @@ class InvoiceService
{
switch ($reminder_template) {
case 'reminder1':
$this->invoice->reminder1_sent = now()->format('Y-m-d');
$this->invoice->reminder_last_sent = now()->format('Y-m-d');
$this->invoice->reminder1_sent = now();
$this->invoice->reminder_last_sent = now();
$this->invoice->last_sent_date = now();
break;
case 'reminder2':
$this->invoice->reminder2_sent = now()->format('Y-m-d');
$this->invoice->reminder_last_sent = now()->format('Y-m-d');
$this->invoice->reminder2_sent = now();
$this->invoice->reminder_last_sent = now();
$this->invoice->last_sent_date = now();
break;
case 'reminder3':
$this->invoice->reminder3_sent = now()->format('Y-m-d');
$this->invoice->reminder_last_sent = now()->format('Y-m-d');
$this->invoice->reminder3_sent = now();
$this->invoice->reminder_last_sent = now();
$this->invoice->last_sent_date = now();
break;
case 'endless_reminder':
$this->invoice->reminder_last_sent = now()->format('Y-m-d');
$this->invoice->reminder_last_sent = now();
$this->invoice->last_sent_date = now();
break;
default:
$this->invoice->reminder1_sent = now()->format('Y-m-d');
$this->invoice->reminder_last_sent = now()->format('Y-m-d');
$this->invoice->reminder1_sent = now();
$this->invoice->reminder_last_sent = now();
$this->invoice->last_sent_date = now();
break;
}

View File

@ -12,6 +12,7 @@
namespace App\Services\Invoice;
use App\Models\Invoice;
use App\Models\RecurringInvoice;
use App\Services\AbstractService;
use Carbon\Carbon;
@ -126,6 +127,14 @@ class UpdateReminder extends AbstractService
$date_collection->push($reminder_date);
}
if ($this->invoice->last_sent_date &&
(int)$this->settings->endless_reminder_frequency_id > 0) {
$reminder_date = $this->addTimeInterval($this->invoice->last_sent_date, (int)$this->settings->num_days_reminder3)->addSeconds($offset);
if ($reminder_date->gt(Carbon::parse($this->invoice->next_send_date)));
$date_collection->push($reminder_date);
}
if($date_collection->count() >=1 && $date_collection->sort()->first()->gte(now()))
$this->invoice->next_send_date = $date_collection->sort()->first();
else
@ -133,4 +142,41 @@ class UpdateReminder extends AbstractService
return $this->invoice;
}
private function addTimeInterval($date, $endless_reminder_frequency_id) :?Carbon
{
if (!$date)
return null;
switch ($endless_reminder_frequency_id) {
case RecurringInvoice::FREQUENCY_DAILY:
return Carbon::parse($date)->addDay()->startOfDay();
case RecurringInvoice::FREQUENCY_WEEKLY:
return Carbon::parse($date)->addWeek()->startOfDay();
case RecurringInvoice::FREQUENCY_TWO_WEEKS:
return Carbon::parse($date)->addWeeks(2)->startOfDay();
case RecurringInvoice::FREQUENCY_FOUR_WEEKS:
return Carbon::parse($date)->addWeeks(4)->startOfDay();
case RecurringInvoice::FREQUENCY_MONTHLY:
return Carbon::parse($date)->addMonthNoOverflow()->startOfDay();
case RecurringInvoice::FREQUENCY_TWO_MONTHS:
return Carbon::parse($date)->addMonthsNoOverflow(2)->startOfDay();
case RecurringInvoice::FREQUENCY_THREE_MONTHS:
return Carbon::parse($date)->addMonthsNoOverflow(3)->startOfDay();
case RecurringInvoice::FREQUENCY_FOUR_MONTHS:
return Carbon::parse($date)->addMonthsNoOverflow(4)->startOfDay();
case RecurringInvoice::FREQUENCY_SIX_MONTHS:
return Carbon::parse($date)->addMonthsNoOverflow(6)->startOfDay();
case RecurringInvoice::FREQUENCY_ANNUALLY:
return Carbon::parse($date)->addYear()->startOfDay();
case RecurringInvoice::FREQUENCY_TWO_YEARS:
return Carbon::parse($date)->addYears(2)->startOfDay();
case RecurringInvoice::FREQUENCY_THREE_YEARS:
return Carbon::parse($date)->addYears(3)->startOfDay();
default:
return null;
}
}
}