Skip to content

Commit 75d45a8

Browse files
authored
Merge pull request #90 from LaswitchTech/dev
General: Version bumped to v0.0.90
2 parents a396dbf + 2a7ba1f commit 75d45a8

6 files changed

Lines changed: 70 additions & 102 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.0.89
1+
v0.0.90

View/432.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
<h2 class="h4 mb-1"><?= $this->Locale->get('Enter your verification code') ?></h2>
55
<p class="opacity-50 mb-0"><?= $this->Locale->get('We sent you a code to your email') ?></p>
66
</div>
7-
<form method="POST" action="<?= $this->Request->getHostAddress() . $this->Request->getUri() . '?' . $this->Request->getQueryString() ?>" class="needs-validation" autocomplete="off" novalidate>
7+
<form method="POST" action="<?= $this->Request->getHostAddress() . $this->Request->getUri() . '?' . str_replace('&resend','',$this->Request->getQueryString()) ?>" class="needs-validation" autocomplete="off" novalidate>
88
<?= $this->CSRF->field(); ?>
99
<div class="mb-3">
1010
<label for="code" class="form-label"><?= $this->Locale->get('Code') ?></label>
1111
<input type="text" class="form-control" name="code" id="code" autocomplete="off" placeholder="000000" value="<?=$this->Request->getParams('GET','verify')?>" required>
1212
<div class="invalid-feedback"><?= $this->Locale->get('Please enter a valid pin.') ?></div>
1313
</div>
1414
<div class="d-flex justify-content-end align-items-center mb-4">
15-
<a href="<?= $this->Request->getHostAddress() . $this->Request->getUri() . '?' . $this->Request->getQueryString() ?>&resend"><?= $this->Locale->get('Request a new code') ?><i class="bi bi-arrow-counterclockwise ms-1"></i></a>
15+
<a href="<?= $this->Request->getHostAddress() . $this->Request->getUri() . '?' . str_replace('&resend','',$this->Request->getQueryString()) ?>&resend"><?= $this->Locale->get('Request a new code') ?><i class="bi bi-arrow-counterclockwise ms-1"></i></a>
1616
</div>
1717
<div class="d-flex justify-content-between align-items-center gap-3 mt-4 mb-2">
1818
<button type="button" class="btn btn-outline-secondary" onclick="window.history.back();"><i class="bi bi-arrow-left me-1"></i><?= $this->Locale->get('Go Back') ?></button>

src/Abstracts/Backend.php

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,6 @@ public function notify(object $user, string $password): bool
182182
->from($user->organization()->email ?? $CONFIG->get('smtp','username'))
183183
->subject('Your account password has been reset')
184184
->body($body)
185-
->var('logo', 'data:'.mime_content_type($CONFIG->root() . '/webroot' . $this->logo()).';base64,' . base64_encode(file_get_contents($CONFIG->root() . '/webroot' . $this->logo())))
186-
->var('brand', $CONFIG->get('application','name'))
187185
->var('greetings', "Sincerely,<br>".$user->organization()->name."'s Team");
188186

189187
// Send the message
@@ -200,45 +198,4 @@ public function notify(object $user, string $password): bool
200198

201199
return $status;
202200
}
203-
204-
/**
205-
* Get the logo path
206-
*
207-
* @return string
208-
*/
209-
protected function logo()
210-
{
211-
// Import Global Variables
212-
global $CONFIG;
213-
214-
$src = '/assets/img/logo.svg';
215-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
216-
$src = '/assets/img/logo.jpg';
217-
}
218-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
219-
$src = '/assets/img/logo.gif';
220-
}
221-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
222-
$src = '/assets/img/logo.webp';
223-
}
224-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
225-
$src = '/assets/img/logo.png';
226-
}
227-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
228-
$src = '/assets/core/img/logo.svg';
229-
}
230-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
231-
$src = '/assets/core/img/logo.jpg';
232-
}
233-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
234-
$src = '/assets/core/img/logo.gif';
235-
}
236-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
237-
$src = '/assets/core/img/logo.webp';
238-
}
239-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
240-
$src = '/assets/core/img/logo.png';
241-
}
242-
return $src;
243-
}
244201
}

src/Objects/Message.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
<?php
22

3-
/**
4-
* Core Framework - Message
5-
*
6-
* @license MIT (https://mit-license.org/)
7-
* @author Louis Ouellet <louis@laswitchtech.com>
8-
*/
9-
103
// Declaring namespace
114
namespace LaswitchTech\Core\Objects;
125

src/Objects/Pin.php

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,6 @@ public function notify(object $user, string $pin, callable $fn): bool
169169
// Configure the message
170170
$eml->to($user->username)
171171
->from($user->organization()->email ?? $CONFIG->get('smtp','username'))
172-
->var('logo', 'data:'.mime_content_type($CONFIG->root() . '/webroot' . $this->logo()).';base64,' . base64_encode(file_get_contents($CONFIG->root() . '/webroot' . $this->logo())))
173-
->var('brand', $CONFIG->get('application','name'))
174172
->var('greetings', "Sincerely,<br>".$user->organization()->name."'s Team");
175173

176174
// Send the message
@@ -188,47 +186,6 @@ public function notify(object $user, string $pin, callable $fn): bool
188186
return $status;
189187
}
190188

191-
/**
192-
* Get the logo path
193-
*
194-
* @return string
195-
*/
196-
private function logo(): string
197-
{
198-
// Import Global Variables
199-
global $CONFIG;
200-
201-
$src = '/assets/img/logo.svg';
202-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
203-
$src = '/assets/img/logo.jpg';
204-
}
205-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
206-
$src = '/assets/img/logo.gif';
207-
}
208-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
209-
$src = '/assets/img/logo.webp';
210-
}
211-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
212-
$src = '/assets/img/logo.png';
213-
}
214-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
215-
$src = '/assets/core/img/logo.svg';
216-
}
217-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
218-
$src = '/assets/core/img/logo.jpg';
219-
}
220-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
221-
$src = '/assets/core/img/logo.gif';
222-
}
223-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
224-
$src = '/assets/core/img/logo.webp';
225-
}
226-
if(!is_file($CONFIG->root() . '/webroot' . $src)){
227-
$src = '/assets/core/img/logo.png';
228-
}
229-
return $src;
230-
}
231-
232189
/**
233190
* Clean up expired pins
234191
*

src/SMTP.php

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
<?php
22

3-
/**
4-
* Core Framework - SMTP
5-
*
6-
* @author LaswitchTech <support@laswitchtech.com>
7-
*/
8-
93
// Declaring namespace
104
namespace LaswitchTech\Core;
115

@@ -40,6 +34,7 @@ class SMTP {
4034
private $templates = [];
4135
private $template;
4236
private $path;
37+
private $vars = [];
4338

4439
/**
4540
* Constructor
@@ -84,6 +79,10 @@ public function __construct()
8479
}
8580
}
8681
}
82+
83+
// Add default vars
84+
$this->var('logo', 'data:'.mime_content_type($this->Config->root() . $this->logo()).';base64,' . base64_encode(file_get_contents($this->Config->root() . $this->logo())));
85+
$this->var('brand', $this->Config->get('application','name'));
8786
}
8887

8988
/**
@@ -382,15 +381,77 @@ public function set(string $name): self
382381
return $this;
383382
}
384383

384+
/**
385+
* Set a variable to be replaced in the template.
386+
*
387+
* @param string $key
388+
* @param mixed $value
389+
* @return self
390+
*/
391+
public function var(string $key, mixed $value): self
392+
{
393+
$this->vars[$key] = $value;
394+
return $this;
395+
}
396+
397+
/**
398+
* Create a new message instance.
399+
*
400+
* @return Message
401+
*/
385402
public function message(): Message
386403
{
387404
if(!$this->isAuthenticated()){ $this->authenticate(); }
388405
$message = new Message($this->connection);
389406
$message->template(file_get_contents($this->templates[$this->template]));
390407
$message->from($this->username);
408+
foreach($this->vars as $key => $value){
409+
$message->var($key, $value);
410+
}
391411
return $message;
392412
}
393413

414+
/**
415+
* Get the logo path
416+
*
417+
* @return string
418+
*/
419+
private function logo(): string
420+
{
421+
// Import Global Variables
422+
global $CONFIG;
423+
424+
$src = '/assets/img/logo.svg';
425+
if(!is_file($CONFIG->root() . $src)){
426+
$src = '/assets/img/logo.png';
427+
}
428+
if(!is_file($CONFIG->root() . $src)){
429+
$src = '/assets/img/logo.jpg';
430+
}
431+
if(!is_file($CONFIG->root() . $src)){
432+
$src = '/assets/img/logo.gif';
433+
}
434+
if(!is_file($CONFIG->root() . $src)){
435+
$src = '/assets/img/logo.webp';
436+
}
437+
if(!is_file($CONFIG->root() . $src)){
438+
$src = '/vendor/laswitchtech/core/img/logo.svg';
439+
}
440+
if(!is_file($CONFIG->root() . $src)){
441+
$src = '/vendor/laswitchtech/core/img/logo.png';
442+
}
443+
if(!is_file($CONFIG->root() . $src)){
444+
$src = '/vendor/laswitchtech/core/img/logo.jpg';
445+
}
446+
if(!is_file($CONFIG->root() . $src)){
447+
$src = '/vendor/laswitchtech/core/img/logo.gif';
448+
}
449+
if(!is_file($CONFIG->root() . $src)){
450+
$src = '/vendor/laswitchtech/core/img/logo.webp';
451+
}
452+
return $src;
453+
}
454+
394455
/**
395456
* Install the module
396457
*

0 commit comments

Comments
 (0)