Skip to content

Commit 95171a3

Browse files
committed
Better user creation email.
1 parent 3240601 commit 95171a3

File tree

5 files changed

+14
-20
lines changed

5 files changed

+14
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
1212
### Changed
1313
* `[pre.2]` — File Manager now displays relevant information on all screen sizes, and includes better button clicking mechanics for dropdown menu.
1414
* 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.
15+
* User creation emails include more information and are sent by the event listener rather than the repository.
1516

1617
## v0.6.0-pre.2 (Courageous Carniadactylus)
1718
### Fixed

app/Notifications/AccountCreated.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ class AccountCreated extends Notification implements ShouldQueue
4545
*
4646
* @return void
4747
*/
48-
public function __construct($token)
48+
public function __construct(array $user)
4949
{
50-
$this->token = $token;
50+
$this->user = $user;
5151
}
5252

5353
/**
@@ -70,8 +70,10 @@ public function via($notifiable)
7070
public function toMail($notifiable)
7171
{
7272
return (new MailMessage)
73-
->line('You are recieving this email because an account has been created for you on Pterodactyl Panel.')
74-
->line('Email: ' . $notifiable->email)
75-
->action('Setup Your Account', url('/auth/password/reset/' . $this->token . '?email=' . $notifiable->email));
73+
->greeting('Hello ' . $this->user->name . '!')
74+
->line('You are recieving this email because an account has been created for you on Pterodactyl Panel.')
75+
->line('Username: ' . $this->user->username)
76+
->line('Email: ' . $notifiable->email)
77+
->action('Setup Your Account', url('/auth/password/reset/' . $this->user->token . '?email=' . $notifiable->email));
7678
}
7779
}

app/Notifications/SendPasswordReset.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,4 @@ public function toMail($notifiable)
7575
->action('Reset Password', url('auth/password/reset', $this->token))
7676
->line('If you did not request a password reset, no further action is required.');
7777
}
78-
79-
/**
80-
* Get the array representation of the notification.
81-
*
82-
* @param mixed $notifiable
83-
* @return array
84-
*/
85-
public function toArray($notifiable)
86-
{
87-
return [
88-
//
89-
];
90-
}
9178
}

app/Observers/UserObserver.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ public function creating(User $user)
4949
public function created(User $user)
5050
{
5151
event(new Events\User\Created($user));
52+
53+
$user->notify((new AccountCreated([
54+
'name' => $user->name_first,
55+
'username' => $user->username,
56+
'token' => DB::table('password_resets')->where('email', $user->email)->orderBy('created_at', 'desc')->first(),
57+
])));
5258
}
5359

5460
/**

app/Repositories/UserRepository.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ public function create(array $data)
105105
'token' => $token,
106106
'created_at' => Carbon::now()->toDateTimeString(),
107107
]);
108-
109-
$user->notify((new AccountCreated($token)));
110108
}
111109

112110
DB::commit();

0 commit comments

Comments
 (0)