From 95171a3e41f2baa1341f43a2e063cca376150168 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Fri, 17 Feb 2017 18:48:57 -0500 Subject: [PATCH] Better user creation email. --- CHANGELOG.md | 1 + app/Notifications/AccountCreated.php | 12 +++++++----- app/Notifications/SendPasswordReset.php | 13 ------------- app/Observers/UserObserver.php | 6 ++++++ app/Repositories/UserRepository.php | 2 -- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 799344e45..42fcb0463 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. ### Changed * `[pre.2]` — File Manager now displays relevant information on all screen sizes, and includes better button clicking mechanics for dropdown menu. * Reduced the number of database queries being executed when viewing a specific server. This is done by caching the query for up to 60 minutes in memcached. +* User creation emails include more information and are sent by the event listener rather than the repository. ## v0.6.0-pre.2 (Courageous Carniadactylus) ### Fixed diff --git a/app/Notifications/AccountCreated.php b/app/Notifications/AccountCreated.php index 55cfe416b..1c3d04de3 100644 --- a/app/Notifications/AccountCreated.php +++ b/app/Notifications/AccountCreated.php @@ -45,9 +45,9 @@ class AccountCreated extends Notification implements ShouldQueue * * @return void */ - public function __construct($token) + public function __construct(array $user) { - $this->token = $token; + $this->user = $user; } /** @@ -70,8 +70,10 @@ class AccountCreated extends Notification implements ShouldQueue public function toMail($notifiable) { return (new MailMessage) - ->line('You are recieving this email because an account has been created for you on Pterodactyl Panel.') - ->line('Email: ' . $notifiable->email) - ->action('Setup Your Account', url('/auth/password/reset/' . $this->token . '?email=' . $notifiable->email)); + ->greeting('Hello ' . $this->user->name . '!') + ->line('You are recieving this email because an account has been created for you on Pterodactyl Panel.') + ->line('Username: ' . $this->user->username) + ->line('Email: ' . $notifiable->email) + ->action('Setup Your Account', url('/auth/password/reset/' . $this->user->token . '?email=' . $notifiable->email)); } } diff --git a/app/Notifications/SendPasswordReset.php b/app/Notifications/SendPasswordReset.php index 31939945e..a3bddb825 100644 --- a/app/Notifications/SendPasswordReset.php +++ b/app/Notifications/SendPasswordReset.php @@ -75,17 +75,4 @@ class SendPasswordReset extends Notification implements ShouldQueue ->action('Reset Password', url('auth/password/reset', $this->token)) ->line('If you did not request a password reset, no further action is required.'); } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Observers/UserObserver.php b/app/Observers/UserObserver.php index e0624e268..7a7b7ba46 100644 --- a/app/Observers/UserObserver.php +++ b/app/Observers/UserObserver.php @@ -49,6 +49,12 @@ class UserObserver public function created(User $user) { event(new Events\User\Created($user)); + + $user->notify((new AccountCreated([ + 'name' => $user->name_first, + 'username' => $user->username, + 'token' => DB::table('password_resets')->where('email', $user->email)->orderBy('created_at', 'desc')->first(), + ]))); } /** diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index 68ae134f1..5ab2edbbf 100644 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -105,8 +105,6 @@ class UserRepository 'token' => $token, 'created_at' => Carbon::now()->toDateTimeString(), ]); - - $user->notify((new AccountCreated($token))); } DB::commit();