Skip to content

Commit 5efee34

Browse files
committed
1 parent 10e2e6e commit 5efee34

File tree

11 files changed

+111
-135
lines changed

11 files changed

+111
-135
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
77
### Fixed
88
* `[beta.3]` — Fixes a bug with the default environment file that was causing an inability to perform a fresh install when running package discovery.
99
* `[beta.3]` — Fixes an edge case caused by the Laravel 5.5 upgrade that would try to perform an in_array check aganist a null value.
10+
* `[beta.3]` — Fixes a bug that would cause an error when attempting to create a new user on the Panel.
1011

1112
## v0.7.0-beta.3 (Derelict Dermodactylus)
1213
### Fixed

app/Http/Controllers/Admin/UserController.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
use Pterodactyl\Http\Controllers\Controller;
1010
use Illuminate\Contracts\Translation\Translator;
1111
use Pterodactyl\Services\Users\UserUpdateService;
12+
use Pterodactyl\Traits\Helpers\AvailableLanguages;
1213
use Pterodactyl\Services\Users\UserCreationService;
1314
use Pterodactyl\Services\Users\UserDeletionService;
1415
use Pterodactyl\Http\Requests\Admin\UserFormRequest;
1516
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
1617

1718
class UserController extends Controller
1819
{
20+
use AvailableLanguages;
21+
1922
/**
2023
* @var \Prologue\Alerts\AlertsMessageBag
2124
*/
@@ -92,7 +95,9 @@ public function index(Request $request)
9295
*/
9396
public function create()
9497
{
95-
return view('admin.users.new');
98+
return view('admin.users.new', [
99+
'languages' => $this->getAvailableLanguages(true),
100+
]);
96101
}
97102

98103
/**
@@ -103,7 +108,10 @@ public function create()
103108
*/
104109
public function view(User $user)
105110
{
106-
return view('admin.users.view', ['user' => $user]);
111+
return view('admin.users.view', [
112+
'user' => $user,
113+
'languages' => $this->getAvailableLanguages(true),
114+
]);
107115
}
108116

109117
/**

app/Http/Requests/Admin/AdminFormRequest.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Http\Requests\Admin;
114

@@ -39,11 +32,11 @@ public function authorize()
3932
* Return only the fields that we are interested in from the request.
4033
* This will include empty fields as a null value.
4134
*
42-
* @param array $only
35+
* @param array|null $only
4336
* @return array
4437
*/
45-
public function normalize($only = [])
38+
public function normalize(array $only = null)
4639
{
47-
return $this->all(empty($only) ? array_keys($this->rules()) : $only);
40+
return $this->only($only ?? array_keys($this->rules()));
4841
}
4942
}

app/Http/Requests/Admin/UserFormRequest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ public function rules()
2222
return User::getCreateRules();
2323
}
2424

25-
public function normalize($only = [])
25+
/**
26+
* @param array|null $only
27+
* @return array
28+
*/
29+
public function normalize(array $only = null)
2630
{
2731
if ($this->method === 'PATCH') {
2832
return array_merge(
2933
$this->all(['password']),
30-
$this->only(['email', 'username', 'name_first', 'name_last', 'root_admin', 'ignore_connection_error'])
34+
$this->only(['email', 'username', 'name_first', 'name_last', 'root_admin', 'language', 'ignore_connection_error'])
3135
);
3236
}
3337

app/Models/User.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Models;
114

@@ -127,6 +120,8 @@ class User extends Model implements
127120
'name_first' => 'required',
128121
'name_last' => 'required',
129122
'password' => 'sometimes',
123+
'language' => 'sometimes',
124+
'use_totp' => 'sometimes',
130125
];
131126

132127
/**

app/Observers/UserObserver.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,21 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Observers;
114

125
use Pterodactyl\Events;
136
use Pterodactyl\Models\User;
14-
use Pterodactyl\Services\Components\UuidService;
157

168
class UserObserver
179
{
1810
protected $uuid;
1911

20-
public function __construct(UuidService $uuid)
21-
{
22-
$this->uuid = $uuid;
23-
}
24-
2512
/**
2613
* Listen to the User creating event.
2714
*
2815
* @param \Pterodactyl\Models\User $user
2916
*/
3017
public function creating(User $user)
3118
{
32-
$user->uuid = $this->uuid->generate('users', 'uuid');
33-
3419
event(new Events\User\Creating($user));
3520
}
3621

app/Services/Components/UuidService.php

Lines changed: 0 additions & 63 deletions
This file was deleted.

app/Services/Users/UserCreationService.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace Pterodactyl\Services\Users;
1111

12+
use Ramsey\Uuid\Uuid;
1213
use Illuminate\Foundation\Application;
1314
use Illuminate\Contracts\Hashing\Hasher;
1415
use Illuminate\Database\ConnectionInterface;
@@ -96,7 +97,10 @@ public function handle(array $data)
9697
$token = $this->passwordService->handle($data['email']);
9798
}
9899

99-
$user = $this->repository->create($data);
100+
$user = $this->repository->create(array_merge($data, [
101+
'uuid' => Uuid::uuid4()->toString(),
102+
]));
103+
100104
$this->connection->commit();
101105

102106
// @todo fire event, handle notification there

resources/themes/pterodactyl/admin/users/new.blade.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@
5151
<input type="text" autocomplete="off" name="name_last" value="{{ old('name_last') }}" class="form-control" />
5252
</div>
5353
</div>
54+
<div class="form-group">
55+
<label class="control-label">Default Langauge</label>
56+
<div>
57+
<select name="language" class="form-control">
58+
@foreach($languages as $key => $value)
59+
<option value="{{ $key }}" @if(config('app.locale') === $key) selected @endif>{{ $value }}</option>
60+
@endforeach
61+
</select>
62+
<p class="text-muted"><small>The default language to use when rendering the Panel for this user.</small></p>
63+
</div>
64+
</div>
5465
</div>
5566
<div class="box-footer">
5667
{!! csrf_field() !!}

resources/themes/pterodactyl/admin/users/view.blade.php

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@
5151
<input readonly type="text" name="name_last" value="{{ $user->name_last }}" class="form-control form-autocomplete-stop">
5252
</div>
5353
</div>
54+
<div class="form-group">
55+
<label class="control-label">Default Langauge</label>
56+
<div>
57+
<select name="language" class="form-control">
58+
@foreach($languages as $key => $value)
59+
<option value="{{ $key }}" @if($user->language === $key) selected @endif>{{ $value }}</option>
60+
@endforeach
61+
</select>
62+
<p class="text-muted"><small>The default language to use when rendering the Panel for this user.</small></p>
63+
</div>
64+
</div>
5465
</div>
5566
<div class="box-footer">
5667
{!! csrf_field() !!}
@@ -101,25 +112,24 @@
101112
</div>
102113
</div>
103114
</form>
104-
<div class="col-xs-12">
105-
<div class="box">
106-
<div class="box-header with-border">
107-
<h3 class="box-title">Associated Servers</h3>
108-
</div>
109-
<div class="box-body table-responsive no-padding">
110-
<table class="table table-hover">
111-
<thead>
112-
<tr>
113-
<th style="width:2%;"></th>
114-
<th>Identifier</th>
115-
<th>Server Name</th>
116-
<th>Access</th>
117-
<th>Node</th>
118-
<th style="width:10%;"></th>
119-
</tr>
120-
</thead>
121-
<tbody>
122-
Oh dear, this hasn't been fixed yet?
115+
{{--<div class="col-xs-12">--}}
116+
{{--<div class="box">--}}
117+
{{--<div class="box-header with-border">--}}
118+
{{--<h3 class="box-title">Associated Servers</h3>--}}
119+
{{--</div>--}}
120+
{{--<div class="box-body table-responsive no-padding">--}}
121+
{{--<table class="table table-hover">--}}
122+
{{--<thead>--}}
123+
{{--<tr>--}}
124+
{{--<th style="width:2%;"></th>--}}
125+
{{--<th>Identifier</th>--}}
126+
{{--<th>Server Name</th>--}}
127+
{{--<th>Access</th>--}}
128+
{{--<th>Node</th>--}}
129+
{{--<th style="width:10%;"></th>--}}
130+
{{--</tr>--}}
131+
{{--</thead>--}}
132+
{{--<tbody>--}}
123133
{{--@foreach($user->setAccessLevel('subuser')->access()->get() as $server)--}}
124134
{{--<tr>--}}
125135
{{--<td><a href="{{ route('server.index', $server->uuidShort) }}/"><i class="fa fa-tachometer"></i></a></td>--}}
@@ -136,12 +146,11 @@
136146
{{--<td class="centered">@if($server->suspended === 0)<span class="label muted muted-hover label-success">Active</span>@else<span class="label label-warning">Suspended</span>@endif</td>--}}
137147
{{--</td>--}}
138148
{{--@endforeach--}}
139-
</tbody>
140-
</table>
141-
</div>
142-
</form>
143-
</div>
144-
</div>
149+
{{--</tbody>--}}
150+
{{--</table>--}}
151+
{{--</div>--}}
152+
{{--</div>--}}
153+
{{--</div>--}}
145154
<div class="col-xs-12">
146155
<div class="box box-danger">
147156
<div class="box-header with-border">

0 commit comments

Comments
 (0)