Merge branch 'feature/vuejs' into feature/vuejs-account
This commit is contained in:
commit
603b8a3094
52 changed files with 666 additions and 529 deletions
|
@ -1,59 +0,0 @@
|
|||
<?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\Services\Helpers;
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Illuminate\Contracts\Hashing\Hasher;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
|
||||
class TemporaryPasswordService
|
||||
{
|
||||
const HMAC_ALGO = 'sha256';
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Database\ConnectionInterface
|
||||
*/
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Hashing\Hasher
|
||||
*/
|
||||
protected $hasher;
|
||||
|
||||
/**
|
||||
* TemporaryPasswordService constructor.
|
||||
*
|
||||
* @param \Illuminate\Database\ConnectionInterface $connection
|
||||
* @param \Illuminate\Contracts\Hashing\Hasher $hasher
|
||||
*/
|
||||
public function __construct(ConnectionInterface $connection, Hasher $hasher)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
$this->hasher = $hasher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a password reset token for a specific email address.
|
||||
*
|
||||
* @param string $email
|
||||
* @return string
|
||||
*/
|
||||
public function handle($email)
|
||||
{
|
||||
$token = hash_hmac(self::HMAC_ALGO, Uuid::uuid4()->toString(), config('app.key'));
|
||||
|
||||
$this->connection->table('password_resets')->insert([
|
||||
'email' => $email,
|
||||
'token' => $this->hasher->make($token),
|
||||
]);
|
||||
|
||||
return $token;
|
||||
}
|
||||
}
|
|
@ -78,7 +78,7 @@ class EnvironmentService
|
|||
}
|
||||
|
||||
// Process variables set in the configuration file.
|
||||
foreach ($this->config->get('pterodactyl.environment_mappings', []) as $key => $object) {
|
||||
foreach ($this->config->get('pterodactyl.environment_variables', []) as $key => $object) {
|
||||
if (is_callable($object)) {
|
||||
$variables[$key] = call_user_func($object, $server);
|
||||
} else {
|
||||
|
|
|
@ -56,6 +56,8 @@ class PermissionCreationService
|
|||
}
|
||||
}
|
||||
|
||||
$this->repository->withoutFreshModel()->insert($insertPermissions);
|
||||
if (! empty($insertPermissions)) {
|
||||
$this->repository->withoutFreshModel()->insert($insertPermissions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ namespace Pterodactyl\Services\Users;
|
|||
use Ramsey\Uuid\Uuid;
|
||||
use Illuminate\Contracts\Hashing\Hasher;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Contracts\Auth\PasswordBroker;
|
||||
use Pterodactyl\Notifications\AccountCreated;
|
||||
use Pterodactyl\Services\Helpers\TemporaryPasswordService;
|
||||
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
||||
|
||||
class UserCreationService
|
||||
|
@ -22,9 +22,9 @@ class UserCreationService
|
|||
private $hasher;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Helpers\TemporaryPasswordService
|
||||
* @var \Illuminate\Contracts\Auth\PasswordBroker
|
||||
*/
|
||||
private $passwordService;
|
||||
private $passwordBroker;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface
|
||||
|
@ -36,18 +36,18 @@ class UserCreationService
|
|||
*
|
||||
* @param \Illuminate\Database\ConnectionInterface $connection
|
||||
* @param \Illuminate\Contracts\Hashing\Hasher $hasher
|
||||
* @param \Pterodactyl\Services\Helpers\TemporaryPasswordService $passwordService
|
||||
* @param \Illuminate\Contracts\Auth\PasswordBroker $passwordBroker
|
||||
* @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository
|
||||
*/
|
||||
public function __construct(
|
||||
ConnectionInterface $connection,
|
||||
Hasher $hasher,
|
||||
TemporaryPasswordService $passwordService,
|
||||
PasswordBroker $passwordBroker,
|
||||
UserRepositoryInterface $repository
|
||||
) {
|
||||
$this->connection = $connection;
|
||||
$this->hasher = $hasher;
|
||||
$this->passwordService = $passwordService;
|
||||
$this->passwordBroker = $passwordBroker;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
@ -68,8 +68,8 @@ class UserCreationService
|
|||
|
||||
$this->connection->beginTransaction();
|
||||
if (! isset($data['password']) || empty($data['password'])) {
|
||||
$generateResetToken = true;
|
||||
$data['password'] = $this->hasher->make(str_random(30));
|
||||
$token = $this->passwordService->handle($data['email']);
|
||||
}
|
||||
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
|
@ -77,6 +77,10 @@ class UserCreationService
|
|||
'uuid' => Uuid::uuid4()->toString(),
|
||||
]), true, true);
|
||||
|
||||
if (isset($generateResetToken)) {
|
||||
$token = $this->passwordBroker->createToken($user);
|
||||
}
|
||||
|
||||
$this->connection->commit();
|
||||
$user->notify(new AccountCreated($user, $token ?? null));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue