Skip to content

Commit

Permalink
Merge pull request #133 from Thomas-More-Digital-Innovation/sc-FixMail
Browse files Browse the repository at this point in the history
Verificatiemail error gefixt en vertalingen van department head en me…
  • Loading branch information
SiebeCamerman authored Jan 2, 2024
2 parents d1ded49 + 7d5af4b commit 73ed94a
Show file tree
Hide file tree
Showing 14 changed files with 297 additions and 33 deletions.
2 changes: 2 additions & 0 deletions code/webapp/app/Http/Controllers/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Models\User;
use App\Models\UserList;
use App\Notifications\Survey;
use App\Notifications\CreateAccountApp;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
Expand Down Expand Up @@ -81,6 +82,7 @@ public function store(StoreUserRequest $request): RedirectResponse
$user = User::create($request->all());

event(new Registered($user));
$user->notify(new CreateAccountApp(env('APP_URL')."/user#Pass"));

for ($i = 0; $i <= $request->totalDep; $i++) {
$department = $request->input("department" . $i);
Expand Down
10 changes: 6 additions & 4 deletions code/webapp/app/Http/Controllers/MentorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\Models\User;
use App\Models\UserType;
use App\Models\UserList;
use App\Notifications\CreateAccountWebApp;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
use Illuminate\Auth\Events\Registered;
Expand Down Expand Up @@ -53,8 +54,8 @@ public function create()
Gate::authorize("adminOrDep");

$departments = Department::all();
$roles = Role::where("name", "Department Head")
->orWhere("name", "Mentor")
$roles = Role::where("name", "Afdelingshoofd")
->orWhere("name", "Begeleider")
->get();
return view("mentors.create", compact("departments", "roles"));
}
Expand All @@ -76,6 +77,7 @@ public function store(StoreUserRequest $request): RedirectResponse
$user = User::create($request->all());

event(new Registered($user));
$user->notify(new CreateAccountWebApp(env('APP_URL')));

for ($i = 0; $i <= $request->totalDep; $i++) {
$department = $request->input("department" . $i);
Expand Down Expand Up @@ -115,8 +117,8 @@ public function edit($id)
Gate::authorize("editAccount", $id);
$mentor = User::find($id);
$departments = Department::all();
$roles = Role::where("name", "Department Head")
->orWhere("name", "Mentor")
$roles = Role::where("name", "Afdelingshoofd")
->orWhere("name", "Begeleider")
->get();
$departmentsList = DepartmentList::where("user_id", $id)->get();
return view("mentors.edit", compact("mentor", "departments", "roles"), [
Expand Down
64 changes: 64 additions & 0 deletions code/webapp/app/Mail/CreateAccountApp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace App\Mail;

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;
use Illuminate\Notifications\Notifiable;
use App\Models\InfoContent;

class CreateAccountApp extends Mailable
{
use Queueable, SerializesModels;
public $url;
public $infoContent;
public $actionText;

/**
* Create a new message instance.
*
* @return void
*/
public function __construct($url)
{
$this->url = $url;
$this->infoContent = InfoContent::where("info_id", 4)
->get()
->first(); //info_id: 3 = account create webapp mail in database
$this->actionText = "Wijzig Wachtwoord"; //Text on button in mail
}

/**
* Get the message envelope.
*
* @return \Illuminate\Mail\Mailables\Envelope
*/
public function envelope()
{
return new Envelope(subject: $this->infoContent->title);
}

/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Content
*/
public function content()
{
return new Content(markdown: "vendor.notifications.email");
}

/**
* Get the attachments for the message.
*
* @return array
*/
public function attachments()
{
return [];
}
}
64 changes: 64 additions & 0 deletions code/webapp/app/Mail/CreateAccountWebApp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace App\Mail;

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;
use Illuminate\Notifications\Notifiable;
use App\Models\InfoContent;

class CreateAccountWebApp extends Mailable
{
use Queueable, SerializesModels;
public $url;
public $infoContent;
public $actionText;

/**
* Create a new message instance.
*
* @return void
*/
public function __construct($url)
{
$this->url = $url;
$this->infoContent = InfoContent::where("info_id", 3)
->get()
->first(); //info_id: 3 = account create webapp mail in database
$this->actionText = "Inloggen"; //Text on button in mail
}

/**
* Get the message envelope.
*
* @return \Illuminate\Mail\Mailables\Envelope
*/
public function envelope()
{
return new Envelope(subject: $this->infoContent->title);
}

/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Content
*/
public function content()
{
return new Content(markdown: "vendor.notifications.email");
}

/**
* Get the attachments for the message.
*
* @return array
*/
public function attachments()
{
return [];
}
}
4 changes: 2 additions & 2 deletions code/webapp/app/Mail/PasswordReset.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class PasswordReset extends Mailable
public function __construct($url)
{
$this->url = $url;
$this->infoContent = InfoContent::where("info_id", 4)
$this->infoContent = InfoContent::where("info_id", 5)
->get()
->first(); //info_id: 4 = password_reset mail in database
->first(); //info_id: 5 = password_reset mail in database
$this->actionText = "Reset wachtwoord"; //Text on button in mail
}

Expand Down
60 changes: 60 additions & 0 deletions code/webapp/app/Notifications/CreateAccountApp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use App\Mail\CreateAccountApp as CreateAccountAppMailable;

class CreateAccountApp extends Notification
{
use Queueable;
public $url;

/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($url)
{
$this->url = $url;
}

/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ["mail"];
}

/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new CreateAccountAppMailable($this->url))->to($notifiable->email);
}

/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
60 changes: 60 additions & 0 deletions code/webapp/app/Notifications/CreateAccountWebApp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use App\Mail\CreateAccountWebApp as CreateAccountWebAppMailable;

class CreateAccountWebApp extends Notification
{
use Queueable;
public $url;

/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($url)
{
$this->url = $url;
}

/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ["mail"];
}

/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new CreateAccountWebAppMailable($this->url))->to($notifiable->email);
}

/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
2 changes: 1 addition & 1 deletion code/webapp/app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class EventServiceProvider extends ServiceProvider
* @var array<class-string, array<int, class-string>>
*/
protected $listen = [
Registered::class => [SendEmailVerificationNotification::class],
Registered::class => [],
];

/**
Expand Down
37 changes: 24 additions & 13 deletions code/webapp/database/seeders/MailContentSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,40 @@ public function run()
"info_id" => "1",
]);
DB::table("info_contents")->insert([
"title" => "Account aangemaakt voor Waaiburg Web applicatie",
"title" => "Account verifiëren voor Waaiburg Web applicatie",
"info_id" => "2",
"content" => 'Beste, <br><br>Er is een account aangemaakt voor de webapp van De Waaiburg. Via onderstaande link kan u uw account verifiëren.
<br><br>Is deze link verlopen, ga dan naar de inlog pagina, vul je email adres in, en klik op wachtwoord vergeten.',
"content" => 'Beste,<br><br>
Om uw account te activeren, vragen we u vriendelijk om de knop te gebruiken voor verificatie.<br><br>
Mocht deze link niet meer geldig zijn, log dan opnieuw in en vraag eenvoudig een nieuwe verificatie link aan.',
]);
DB::table("info_contents")->insert([
"title" => "Account aangemaakt voor APP",
"title" => "Account aangemaakt voor WebApp",
"info_id" => "3",
"content" => 'Beste, <br><br>Er is een Waaiburg account aangemaakt voor u.<br><br>
Download de Waaiburg app via de App Store op iOS of via de Play Store op Android, ga naar de inlog pagina, vul je e-mailadres in en klik op "Wachtwoord vergeten?".
<br><br>Wil je meteen je account verifieren? Dat kan via onderstaande link:',
"content" => 'Welkom!<br>
We hebben een account voor je aangemaakt.<br>
Klik onderstaande knop om in te loggen met dit tijdelijk wachtwoord: "veranderMij"
<br><br>
Zodra je bent ingelogd, raden we je aan om je wachtwoord meteen te wijzigen voor de veiligheid van je account.
<br><br>
We kijken ernaar uit je op De Waaiburg WebApp te verwelkomen!',
]);
DB::table("info_contents")->insert([
"title" => "Wachtwoord vergeten voor WebApp",
"title" => "Account aangemaakt voor APP",
"info_id" => "4",
"content" => 'Beste, <br><br>Via onderstaande link kun je je wachtwoord opnieuw instellen.
Is de link verlopen of ongeldig, ga dan naar de inlog-pagina, vul je e-mailadres in en klik op "Wachtwoord vergeten?".',
"content" => 'Welkom!<br>
We hebben een account voor je aangemaakt.<br>
Gebruik de onderstaande knop om in te loggen met het tijdelijke wachtwoord: "veranderMij"<br><br>
Zodra je bent ingelogd, raden we je aan om onmiddellijk je wachtwoord te wijzigen in de webapplicatie om de veiligheid van je account te waarborgen.<br>
Na het wijzigen van je wachtwoord kun je "De Waaiburg" app downloaden. Log daar in en begin aan je avontuur!<br><br>
Link naar de App Store: https://apps.apple.com/be/app/de-waaiburg/id1592280272?l=nl <br>
Link naar de Google Play Store: https://play.google.com/store/apps/details?id=com.dewaaiburg',
]);
DB::table("info_contents")->insert([
"title" => "Wachtwoord vergeten voor APP",
"title" => "Wachtwoord vergeten",
"info_id" => "5",
"content" => 'Beste, <br><br>Via onderstaande link kun je je wachtwoord opnieuw instellen.
Is de link verlopen of ongeldig, ga dan naar de inlog-pagina, vul je e-mailadres in en klik op "Wachtwoord vergeten?".',
"content" => 'Beste,<br><br>
Via onderstaande link kun je je wachtwoord opnieuw instellen. <br>
Mocht deze link niet meer geldig zijn, klik dan op "wachtwoord vergeten" op de inlog-pagina en vraag eenvoudig een nieuwe verificatie link aan.',
]);
DB::table("info_contents")->insert([
"title" => "Tevredenheidsmeting beschikbaar",
Expand Down
Loading

0 comments on commit 73ed94a

Please sign in to comment.