Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion app/Mail/OAuth2PasswordlessOTPMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,57 @@ class OAuth2PasswordlessOTPMail extends Mailable
*/
public $reset_password_link_lifetime;

/**
* @var string|null
*/
public $client_app_name;

/**
* @var string|null
*/
public $client_terms_of_services_uri;

/**
* @var string|null
*/
public $client_policy_uri;

/**
* @var string|null
*/
public $client_scope_descriptions;

/**
* @param string $to
* @param string $otp
* @param int $lifetime
* @param string|null $reset_password_link
* @param string|null $client_app_name
* @param string|null $client_terms_of_services_uri
* @param string|null $client_policy_uri
* @param array|null $client_scope_descriptions
*/
public function __construct
(
string $to,
string $otp,
int $lifetime,
string $reset_password_link = null
string $reset_password_link = null,
string $client_app_name = null,
string $client_terms_of_services_uri = null,
string $client_policy_uri = null,
?array $client_scope_descriptions = []
)
{
$this->email = trim($to);
$this->otp = trim($otp);
$this->lifetime = $lifetime / 60;
$this->reset_password_link = $reset_password_link;
$this->reset_password_link_lifetime = Config::get("auth.password_reset_lifetime")/60;
$this->client_app_name = $client_app_name;
$this->client_terms_of_services_uri = $client_terms_of_services_uri;
$this->client_policy_uri = $client_policy_uri;
$this->client_scope_descriptions = $client_scope_descriptions;
}
/**
* Build the message.
Expand Down
19 changes: 18 additions & 1 deletion app/Strategies/OTP/OTPChannelEmailStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,31 @@ public function send(IOTPTypeBuilderStrategy $typeBuilderStrategy, OAuth2OTP $ot
$reset_password_link = $request->getResetLink();
}

$client_app_name = null;
$client_terms_of_services_uri = null;
$client_policy_uri = null;
$client_scope_descriptions = null;

if ($otp->hasClient()) {
$client = $otp->getClient();
$client_app_name = $client->getApplicationName();
$client_terms_of_services_uri = $client->getTermOfServiceUri();
$client_policy_uri = $client->getPolicyUri();
$client_scope_descriptions = array_map(function($scope) { return $scope->getShortDescription(); }, $client->getClientScopes());
}

Mail::queue
(
new OAuth2PasswordlessOTPMail
(
$otp->getUserName(),
$value,
$otp->getLifetime(),
$reset_password_link
$reset_password_link,
$client_app_name,
$client_terms_of_services_uri,
$client_policy_uri,
$client_scope_descriptions
)
);
}
Expand Down
47 changes: 42 additions & 5 deletions resources/views/emails/oauth2_passwordless_otp.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@
<div style="font-family:open Sans Helvetica, Arial, sans-serif;font-size:16px;line-height:1;text-align:center;color:#000000;">Code is valid for {{$lifetime}} minutes.</div>
</td>
</tr>
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;padding-right:16px;padding-left:25px;word-break:break-word;">
<div style="font-family:open Sans Helvetica, Arial, sans-serif;font-size:16px;line-height:1;text-align:center;color:#000000;">If you didn't request this, you can ignore this email.</div>
</td>
</tr>
@if(!empty($reset_password_link))
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;">
Expand All @@ -37,6 +32,48 @@
</td>
</tr>
@endif
@if(!is_null($client_app_name))
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;">
<hr style="margin: 10px 0;">
<div style="font-family: Monaco, monospace,OpenSans, Helvetica;font-size:22px;font-weight:bold;line-height:1;text-align:center;color:#000000;">
{!! $client_app_name !!}
</div>
<hr style="margin: 10px 0;">
</td>
</tr>
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;">
<div style="font-family:open Sans Helvetica, Arial, sans-serif;font-size:16px;font-weight:bold;line-height:1;text-align:justify;color:#000000;">
This app would like to:
</div>
</td>
</tr>
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;">
<ul style="list-style-type: none;padding-left: 0;margin-left: 0;">
@foreach($client_scope_descriptions as $client_scope_description)
<li style="font-family:open Sans Helvetica, Arial, sans-serif;font-size:16px;line-height:1;text-align:justify;color:#000000;">
{!! $client_scope_description !!}
</li>
@endforeach
</ul>
</td>
</tr>
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;">
<div style="font-family:open Sans Helvetica, Arial, sans-serif;font-size:16px;line-height:1;text-align:justify;color:#000000;">
** <b>{!! $client_app_name !!}</b> Application and <b>{!! Config::get("app.tenant_name") !!}</b> will use this information in accordance with their respective <a target="_blank" href="{!! $client_terms_of_services_uri !!}">terms of service</a> and <a target="_blank" href="{!! $client_policy_uri !!}">privacy policies</a>.
</div>
<hr style="margin: 20px 0;">
</td>
</tr>
@endif
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;padding-right:16px;padding-left:25px;word-break:break-word;">
<div style="font-family:open Sans Helvetica, Arial, sans-serif;font-size:16px;line-height:1;text-align:center;color:#000000;">If you didn't request this, you can ignore this email.</div>
</td>
</tr>
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;padding-right:25px;padding-left:25px;word-break:break-word;">
<div style="font-family:open Sans Helvetica, Arial, sans-serif;font-size:16px;line-height:1;text-align:center;color:#000000;">Thanks! <br/><br/>{{Config::get('app.tenant_name')}} Support Team</div>
Expand Down
Loading