Fix user creation to use UUIDs correctly

Also updates the notification send method to be cleaner and more maintainable
This commit is contained in:
Dane Everitt 2018-01-01 12:13:08 -06:00
parent 410a0cca9a
commit 4457634127
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
5 changed files with 97 additions and 171 deletions

View file

@ -1,14 +1,8 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Notifications;
use Pterodactyl\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
@ -19,7 +13,15 @@ class AccountCreated extends Notification implements ShouldQueue
use Queueable;
/**
* The password reset token to send.
* The authentication token to be used for the user to set their
* password for the first time.
*
* @var string|null
*/
public $token;
/**
* The user model for the created user.
*
* @var object
*/
@ -28,11 +30,13 @@ class AccountCreated extends Notification implements ShouldQueue
/**
* Create a new notification instance.
*
* @param aray $user
* @param \Pterodactyl\Models\User $user
* @param string|null $token
*/
public function __construct(array $user)
public function __construct(User $user, string $token = null)
{
$this->user = (object) $user;
$this->token = $token;
$this->user = $user;
}
/**
@ -56,12 +60,12 @@ class AccountCreated extends Notification implements ShouldQueue
{
$message = (new MailMessage)
->greeting('Hello ' . $this->user->name . '!')
->line('You are recieving this email because an account has been created for you on Pterodactyl Panel.')
->line('You are recieving this email because an account has been created for you on ' . config('app.name') . '.')
->line('Username: ' . $this->user->username)
->line('Email: ' . $notifiable->email);
->line('Email: ' . $this->user->email);
if (! is_null($this->user->token)) {
return $message->action('Setup Your Account', url('/auth/password/reset/' . $this->user->token . '?email=' . $notifiable->email));
if (! is_null($this->token)) {
return $message->action('Setup Your Account', url('/auth/password/reset/' . $this->token . '?email=' . $this->user->email));
}
return $message;