diff --git a/CHANGELOG.md b/CHANGELOG.md index 29b7c36..ae6fd79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ v1.7 - Fix FLEXIAPI-272 Add Space based email server integration - Fix FLEXIAPI-284 Add configurable admin API Keys - Fix FLEXIAPI-232 Add provisioning email + important redesign of the contacts page +- Fix FLEXIAPI-287 Refactor the emails templates v1.6 ---- diff --git a/flexiapi/app/Account.php b/flexiapi/app/Account.php index c454fd7..67b41a2 100644 --- a/flexiapi/app/Account.php +++ b/flexiapi/app/Account.php @@ -261,6 +261,11 @@ class Account extends Authenticatable return $this->hasMany(AuthToken::class); } + public function currentResetPasswordEmailToken() + { + return $this->hasOne(ResetPasswordEmailToken::class)->where('used', false)->latestOfMany(); + } + public function resetPasswordEmailTokens() { return $this->hasMany(ResetPasswordEmailToken::class)->latest(); diff --git a/flexiapi/app/Http/Controllers/Admin/ProvisioningEmailController.php b/flexiapi/app/Http/Controllers/Admin/ProvisioningEmailController.php index 7fe0423..f7b2aa9 100644 --- a/flexiapi/app/Http/Controllers/Admin/ProvisioningEmailController.php +++ b/flexiapi/app/Http/Controllers/Admin/ProvisioningEmailController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers\Admin; use App\Account; -use App\ResetPasswordEmailToken; use App\Http\Controllers\Controller; use App\Mail\Provisioning; @@ -23,7 +22,7 @@ class ProvisioningEmailController extends Controller ]); } - public function send(int $accountId) + public function send(Request $request, int $accountId) { $account = Account::findOrFail($accountId); $account->provision(); diff --git a/flexiapi/app/Http/Controllers/Admin/ResetPasswordEmailController.php b/flexiapi/app/Http/Controllers/Admin/ResetPasswordEmailController.php index 953f7d0..4133721 100644 --- a/flexiapi/app/Http/Controllers/Admin/ResetPasswordEmailController.php +++ b/flexiapi/app/Http/Controllers/Admin/ResetPasswordEmailController.php @@ -32,7 +32,7 @@ class ResetPasswordEmailController extends Controller $resetPasswordEmail->email = $account->email; $resetPasswordEmail->save(); - Mail::to($account)->send(new ResetPassword($resetPasswordEmail)); + Mail::to($account)->send(new ResetPassword($account)); return redirect()->route('admin.account.activity.index', $account); } diff --git a/flexiapi/app/Http/Middleware/SpaceCheck.php b/flexiapi/app/Http/Middleware/SpaceCheck.php index 6f3e3a9..3bb9feb 100644 --- a/flexiapi/app/Http/Middleware/SpaceCheck.php +++ b/flexiapi/app/Http/Middleware/SpaceCheck.php @@ -43,7 +43,7 @@ class SpaceCheck 'username' => $space->emailServer->username, 'password' => $space->emailServer->password, 'signature' => $space->emailServer->signature ?? config('mail.signature') - ]; + ] + Config::get('mail'); Config::set('mail', $config); } diff --git a/flexiapi/app/Mail/ConfirmedRegistration.php b/flexiapi/app/Mail/ConfirmedRegistration.php index a883419..7fc6120 100644 --- a/flexiapi/app/Mail/ConfirmedRegistration.php +++ b/flexiapi/app/Mail/ConfirmedRegistration.php @@ -1,7 +1,7 @@ account = $account; + public function __construct( + public Account $account + ) { } - public function build() + public function envelope(): Envelope { - return $this->view('mails.confirmed_registration') - ->text('mails.confirmed_registration_text') - ->with(['account' => $this->account]); + return new Envelope( + subject: $this->account->space->name . ': '. __('Registration confirmed'), + ); + } + + public function content(): Content + { + return new Content( + markdown: 'mails.confirmed_registration', + ); } } diff --git a/flexiapi/app/Mail/NewsletterRegistration.php b/flexiapi/app/Mail/NewsletterRegistration.php index 5176984..f12eca1 100644 --- a/flexiapi/app/Mail/NewsletterRegistration.php +++ b/flexiapi/app/Mail/NewsletterRegistration.php @@ -1,7 +1,7 @@ account = $account; + public function __construct( + public Account $account + ) { } - public function build() + public function envelope(): Envelope { - return $this->view('mails.newsletter_registration') - ->text('mails.newsletter_registration_text') - ->with(['account' => $this->account]); + return new Envelope( + subject: $this->account->space->name . ': '. __('Newsletter registration confirmed'), + ); + } + + public function content(): Content + { + return new Content( + markdown: 'mails.newsletter_registration', + ); } } diff --git a/flexiapi/app/Mail/Provisioning.php b/flexiapi/app/Mail/Provisioning.php index 85cc247..924e615 100644 --- a/flexiapi/app/Mail/Provisioning.php +++ b/flexiapi/app/Mail/Provisioning.php @@ -1,41 +1,55 @@ . +*/ namespace App\Mail; -use Illuminate\Bus\Queueable; -use Illuminate\Mail\Mailable; -use Illuminate\Queue\SerializesModels; - use App\Account; +use Illuminate\Bus\Queueable; +use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Mail\Mailable; +use Illuminate\Mail\Mailables\Content; +use Illuminate\Mail\Mailables\Envelope; +use Illuminate\Queue\SerializesModels; + class Provisioning extends Mailable { use Queueable, SerializesModels; - private $account; - - public function __construct(Account $account) - { - $this->account = $account; + public function __construct( + public Account $account + ) { } - public function build() + public function envelope(): Envelope { - return $this->view(view()->exists('mails.provisioning_custom') + return new Envelope( + subject: $this->account->space->name . ': '. __('Provisioning of your device'), + ); + } + + public function content(): Content + { + return new Content( + markdown: view()->exists('mails.provisioning_custom') ? 'mails.provisioning_custom' - : 'mails.provisioning') - ->text(view()->exists('mails.provisioning_text_custom') - ? 'mails.provisioning_text_custom' - : 'mails.provisioning_text') - ->with([ - 'provisioning_link' => route('provisioning.provision', [ - 'provisioning_token' => $this->account->provisioning_token, - 'reset_password' => true - ]), - 'provisioning_qrcode' => route('provisioning.qrcode', [ - 'provisioning_token' => $this->account->provisioning_token, - 'reset_password' => true - ]) - ]); + : 'mails.provisioning', + ); } } diff --git a/flexiapi/app/Mail/RecoverByCode.php b/flexiapi/app/Mail/RecoverByCode.php index 116d2c3..1a371a7 100644 --- a/flexiapi/app/Mail/RecoverByCode.php +++ b/flexiapi/app/Mail/RecoverByCode.php @@ -1,7 +1,7 @@ account = $account; + public function __construct( + public Account $account + ) { } - public function build() + public function envelope(): Envelope { - return $this->view(view()->exists('mails.authentication_custom') - ? 'mails.authentication_custom' - : 'mails.authentication') - ->text(view()->exists('mails.authentication_text_custom') - ? 'mails.authentication_text_custom' - : 'mails.authentication_text') - ->with([ - 'expiration_minutes' => config('app.recovery_code_expiration_minutes'), - 'recovery_code' => $this->account->recovery_code, - 'provisioning_link' => route('provisioning.provision', [ - 'provisioning_token' => $this->account->provisioning_token, - 'reset_password' => true - ]), - 'provisioning_qrcode' => route('provisioning.qrcode', [ - 'provisioning_token' => $this->account->provisioning_token, - 'reset_password' => true - ]) - ]); + return new Envelope( + subject: $this->account->space->name . ': '. __('Account recovery'), + ); + } + + public function content(): Content + { + return new Content( + markdown: view()->exists('mails.recover_by_code_custom') + ? 'mails.recover_by_code_custom' + : 'mails.recover_by_code', + ); } } diff --git a/flexiapi/app/Mail/RegisterValidation.php b/flexiapi/app/Mail/RegisterValidation.php index 8ba4227..a180c18 100644 --- a/flexiapi/app/Mail/RegisterValidation.php +++ b/flexiapi/app/Mail/RegisterValidation.php @@ -1,7 +1,7 @@ account = $account; + public function __construct( + public Account $account + ) { } - public function build() + public function envelope(): Envelope { - return $this->view('mails.register_validate') - ->text('mails.register_validate_text') - ->with([ - 'code' => $this->account->emailChangeCode()->first()->code - ]); + return new Envelope( + subject: $this->account->space->name . ': '. __('Account registered'), + ); + } + + public function content(): Content + { + return new Content( + markdown: 'mails.register_validation', + ); } } diff --git a/flexiapi/app/Mail/ResetPassword.php b/flexiapi/app/Mail/ResetPassword.php index c68110d..4abc43a 100644 --- a/flexiapi/app/Mail/ResetPassword.php +++ b/flexiapi/app/Mail/ResetPassword.php @@ -1,7 +1,7 @@ token = $token; + public function __construct( + public Account $account + ) { } - public function build() + public function envelope(): Envelope { - return $this->view('mails.reset_password') - ->text('mails.reset_password') - ->with([ - 'token' => $this->token - ]); + return new Envelope( + subject: $this->account->space->name . ': '. __('Reset your password'), + ); + } + + public function content(): Content + { + return new Content( + markdown: 'mails.reset_password', + ); } } diff --git a/flexiapi/lang/fr.json b/flexiapi/lang/fr.json index 92ecb23..b4fd6e8 100644 --- a/flexiapi/lang/fr.json +++ b/flexiapi/lang/fr.json @@ -5,6 +5,7 @@ "Account creation": "Création de compte", "Account recovered recently, try again later": "Tentative de récupération de compte récente, retentez ultérieurement", "Account recovery": "Récupération de compte", + "Account registered": "Compte créé", "Account settings": "Paramètres de compte", "Account": "Compte", "Accounts": "Comptes", @@ -22,9 +23,9 @@ "Administration": "Administration", "All the admins will be super admins": "Tous les administrateurs seront super-administrateurs", "Allow a custom CSS theme": "Autoriser un thème CSS personnalisé", - "Allow client settings to be overwritten by the provisioning ones": "Écraser la configuration client avec celle du provisionnement", + "Allow client settings to be overwritten by the provisioning ones": "Écraser la configuration client avec celle du déploiement", "An email will be sent to :email with a unique link allowing the user to reset its password.": "Un email sera envoyé à :email avec un lien unique l'invitant à réinitialiser son mot de passe", - "An email will be sent to :email with a QR Code and provisioning link.": "Un email sera envoyé à :email contenant un QR Code et un lien de provisionnement.", + "An email will be sent to :email with a QR Code and provisioning link.": "Un email sera envoyé à :email contenant un QR Code et un lien de déploiement.", "An email will be sent to this email when someone join the newsletter": "Un email sera envoyé à cette addresse quand quelqu'un rejoint la liste de diffusion", "App Configuration": "Configuration de l'App", "Api Keys": "Clefs d'API", @@ -115,6 +116,7 @@ "Never expire": "N'expire jamais", "New Admin": "Nouvel Admin", "Newsletter registration email address": "Addresse email d'inscription à la liste de diffusion", + "Newsletter registration confirmed": "Confirmation de l'inscription à la newsletter", "Next": "Suivant", "No account yet?": "Pas encore de compte ?", "No email yet": "Pas d'email pour le moment", @@ -131,8 +133,9 @@ "Please enter the new email that you would like to link to your account.": "Veuillez entre l'adresse email que vous souhaitez lier à votre compte.", "Please enter the new phone number that you would like to link to your account.": "Veuillez entrer le numéro de téléphone que vous souhaitez lier à votre compte.", "Protocol": "Protocole", - "Provisioning tokens": "Jetons de provisionnement", - "Provisioning": "Provisionnement", + "Provisioning tokens": "Jetons de déploiement", + "Provisioning": "Déploiement", + "Provisioning of your device": "Déploiement sur votre appareil", "Public registration": "Inscription publiques", "QR Code scanning": "Scan de QR Code", "Realm": "Royaume", @@ -142,12 +145,14 @@ "Register": "Inscription", "Registrar": "Registrar", "Registration introduction": "Présentation lors de l'inscription", + "Registration confirmed": "Confirmation de l'inscription", "Remove": "Remove", "Renew": "Renouveller", "Requests": "Requêtes", "Resend": "Ré-envoyer", "Reset password emails": "Email de réinitialisation de mot de passe", "Reset password": "Réinitialiser le mot de passe", + "Reset your password": "Réinitialiser votre mot de passe", "Reset": "Réinitialiser", "Role": "Rôle", "Scan the following QR Code using an authenticated device and wait a few seconds.": "Scanner le QR Code avec un appareil authentifié et attendez quelques secondes", @@ -156,7 +161,7 @@ "Select a domain": "Sélectionner un domaine", "Select a file": "Choisir un fichier", "Send an email to the user to reset the password": "Envoyer un email à l'utilisateur pour réinitialiser son mot de passe", - "Send an email to the user with provisioning information": "Envoyer un email à l'utilisateur avec les informations de provisionnement", + "Send an email to the user with provisioning information": "Envoyer un email à l'utilisateur avec les informations de déploiement", "Send": "Envoyer", "Settings": "Paramètres", "Sip Adress": "Adresse SIP", diff --git a/flexiapi/resources/views/admin/account/show.blade.php b/flexiapi/resources/views/admin/account/show.blade.php index 93a534d..2aac800 100644 --- a/flexiapi/resources/views/admin/account/show.blade.php +++ b/flexiapi/resources/views/admin/account/show.blade.php @@ -34,6 +34,11 @@ @if ($account->passwords()->count() > 0)
password {{ __('Password') }}: **********
@endif + ++ globe-hemisphere-west + {{ __('Space') }}: {{ $account->domain }} +
@include('admin.account.parts.badges', ['account' => $account])
diff --git a/flexiapi/resources/views/mails/authentication.blade.php b/flexiapi/resources/views/mails/authentication.blade.php deleted file mode 100644 index ebbebb3..0000000 --- a/flexiapi/resources/views/mails/authentication.blade.php +++ /dev/null @@ -1,30 +0,0 @@ - - -Hello,
-
- You are trying to authenticate to {{ space()->name }} using your email account.
- Please enter the code bellow to finish the authentication process.
-
-
- The code is only available {{ $expiration_minutes }} minutes. -
- @endif -
- You can as well configure your new device using the following code or by directly flashing the QRCode:
-
-
- Provisioning link
-
- Regards,
- {{ config('mail.signature') }}
-
Hello,
-
- You are trying to authenticate to {{ space()->name }} using your email account.
- Please enter the code bellow to finish the authentication process.
-
-
- You can as well configure your new device using the following code or by directly flashing the QRCode:
-
-
- Provisioning link
-
- Regards,
- {{ config('mail.signature') }}
-
Hello,
-
- @if (space()->confirmed_registration_text)
- {{ strip_tags(parsedown(space()->confirmed_registration_text)) }}
- @else
- Your SIP account has been successfully created.
- You can now configure this account on any SIP-compatible application using the following parameters:
-
- @endif
+@extends('mails.layout')
- SIP address: sip:{{ $account->identifier }}
- Username: {{ $account->username }}
- Domain: {{ $account->domain }}
-
- @if (!empty(space()?->account_proxy_registrar_address))
- Proxy/registrar address: sip:{{ space()?->account_proxy_registrar_address }}
- @endif
- @if (!empty(config('app.transport_protocol_text')))
- Transport: {{ config('app.transport_protocol_text') }}
- @endif
-
- Regards,
- {{ config('mail.signature') }}
-
Hello,
-- The following email address wants to register to the mailing list: {{ $account->email }}. -
- - \ No newline at end of file +@extends('mails.layout') + +@section('content') +Hello, + +The following email address wants to register to the mailing list: {{ $account->email }}. +@endsection diff --git a/flexiapi/resources/views/mails/newsletter_registration_text.blade.php b/flexiapi/resources/views/mails/newsletter_registration_text.blade.php deleted file mode 100644 index 2962630..0000000 --- a/flexiapi/resources/views/mails/newsletter_registration_text.blade.php +++ /dev/null @@ -1,3 +0,0 @@ -Hello, - -The following email address wants to register to the mailing list: {{ $account->email }}. \ No newline at end of file diff --git a/flexiapi/resources/views/mails/parts/provisioning.blade.php b/flexiapi/resources/views/mails/parts/provisioning.blade.php new file mode 100644 index 0000000..52fdbd4 --- /dev/null +++ b/flexiapi/resources/views/mails/parts/provisioning.blade.php @@ -0,0 +1,9 @@ +To connect your account to the application, click on the following button: + +Hello,
-
- You are trying to authenticate to {{ space()->name }} using your device.
- You can configure your new device by directly flashing the QRCode or using the provisioning link:
+@extends('mails.layout')
-
+@section('content')
+# Welcome to {{ space()->name }}
- Provisioning link: {{ $provisioning_link }}
-
- Regards,
- {{ config('mail.signature') }}
-
Hello,
-
- You are trying to authenticate to {{ space()->name }} using your device.
- You can configure your new device by directly flashing the QRCode or using the provisioning link:
+@extends('mails.layout')
-
- Provisioning link: {{ $provisioning_link }}
-
- Regards,
- {{ config('mail.signature') }}
-
Hello,
-
- You just created an account on {{ space()->name }} using your email account.
- Please enter the following code on the confirmation page:
-
-
- Regards,
- {{ config('mail.signature') }}
-
Hello,
-- You are invited to reset your {{ $token->account->identifier }} account password on {{ space()->name }} via your email account. -
-The following link will be valid for {{ config('app.reset_password_email_token_expiration_minutes')/60 }} hours.
-- - {{ route('account.reset_password_email.change', $token->token) }} - -
-
- Regards,
- {{ config('mail.signature') }}
-
| + |
|