diff --git a/app/Mail/OAuth2PasswordlessOTPMail.php b/app/Mail/OAuth2PasswordlessOTPMail.php index 30b9f2c6..7f6e932a 100644 --- a/app/Mail/OAuth2PasswordlessOTPMail.php +++ b/app/Mail/OAuth2PasswordlessOTPMail.php @@ -59,18 +59,46 @@ 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); @@ -78,6 +106,10 @@ public function __construct $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. diff --git a/app/Strategies/OTP/OTPChannelEmailStrategy.php b/app/Strategies/OTP/OTPChannelEmailStrategy.php index 414ea38e..348a3455 100644 --- a/app/Strategies/OTP/OTPChannelEmailStrategy.php +++ b/app/Strategies/OTP/OTPChannelEmailStrategy.php @@ -75,6 +75,19 @@ 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 @@ -82,7 +95,11 @@ public function send(IOTPTypeBuilderStrategy $typeBuilderStrategy, OAuth2OTP $ot $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 ) ); } diff --git a/resources/views/emails/oauth2_passwordless_otp.blade.php b/resources/views/emails/oauth2_passwordless_otp.blade.php index 9c13a7dc..b5a59fdf 100644 --- a/resources/views/emails/oauth2_passwordless_otp.blade.php +++ b/resources/views/emails/oauth2_passwordless_otp.blade.php @@ -21,11 +21,6 @@
Code is valid for {{$lifetime}} minutes.
- - -
If you didn't request this, you can ignore this email.
- - @if(!empty($reset_password_link)) @@ -37,6 +32,48 @@ @endif + @if(!is_null($client_app_name)) + + +
+
+ {!! $client_app_name !!} +
+
+ + + + +
+ This app would like to: +
+ + + + + + + + + +
+ ** {!! $client_app_name !!} Application and {!! Config::get("app.tenant_name") !!} will use this information in accordance with their respective terms of service and privacy policies. +
+
+ + + @endif + + +
If you didn't request this, you can ignore this email.
+ +
Thanks!

{{Config::get('app.tenant_name')}} Support Team