Merge branch '0.7-develop' into api-fixes

This commit is contained in:
Dane Everitt 2019-12-28 11:12:45 -08:00 committed by GitHub
commit 245f8e85e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 18 deletions

View File

@ -131,7 +131,7 @@ class DatabaseController extends Controller
sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage()) sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage())
)->flash(); )->flash();
redirect()->route('admin.databases')->withInput($request->validated()); return redirect()->route('admin.databases')->withInput($request->validated());
} else { } else {
throw $exception; throw $exception;
} }
@ -165,7 +165,7 @@ class DatabaseController extends Controller
$this->alert->danger( $this->alert->danger(
sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage()) sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage())
)->flash(); )->flash();
$redirect->withInput($request->normalize()); return $redirect->withInput($request->normalize());
} else { } else {
throw $exception; throw $exception;
} }

View File

@ -20,8 +20,6 @@ class LoginController extends Controller
{ {
use AuthenticatesUsers; use AuthenticatesUsers;
const USER_INPUT_FIELD = 'user';
/** /**
* @var \Illuminate\Auth\AuthManager * @var \Illuminate\Auth\AuthManager
*/ */
@ -64,14 +62,14 @@ class LoginController extends Controller
* *
* @var int * @var int
*/ */
protected $lockoutTime; protected $decayMinutes;
/** /**
* After how many attempts should logins be throttled and locked. * After how many attempts should logins be throttled and locked.
* *
* @var int * @var int
*/ */
protected $maxLoginAttempts; protected $maxAttempts;
/** /**
* LoginController constructor. * LoginController constructor.
@ -98,8 +96,8 @@ class LoginController extends Controller
$this->google2FA = $google2FA; $this->google2FA = $google2FA;
$this->repository = $repository; $this->repository = $repository;
$this->lockoutTime = $this->config->get('auth.lockout.time'); $this->decayMinutes = $this->config->get('auth.lockout.time');
$this->maxLoginAttempts = $this->config->get('auth.lockout.attempts'); $this->maxAttempts = $this->config->get('auth.lockout.attempts');
} }
/** /**
@ -112,7 +110,7 @@ class LoginController extends Controller
*/ */
public function login(Request $request) public function login(Request $request)
{ {
$username = $request->input(self::USER_INPUT_FIELD); $username = $request->input($this->username());
$useColumn = $this->getField($username); $useColumn = $this->getField($username);
if ($this->hasTooManyLoginAttempts($request)) { if ($this->hasTooManyLoginAttempts($request)) {
@ -209,20 +207,30 @@ class LoginController extends Controller
{ {
$this->incrementLoginAttempts($request); $this->incrementLoginAttempts($request);
$this->fireFailedLoginEvent($user, [ $this->fireFailedLoginEvent($user, [
$this->getField($request->input(self::USER_INPUT_FIELD)) => $request->input(self::USER_INPUT_FIELD), $this->getField($request->input($this->username())) => $request->input($this->username()),
]); ]);
$errors = [self::USER_INPUT_FIELD => trans('auth.failed')]; $errors = [$this->username() => trans('auth.failed')];
if ($request->expectsJson()) { if ($request->expectsJson()) {
return response()->json($errors, 422); return response()->json($errors, 422);
} }
return redirect()->route('auth.login') return redirect()->route('auth.login')
->withInput($request->only(self::USER_INPUT_FIELD)) ->withInput($request->only($this->username()))
->withErrors($errors); ->withErrors($errors);
} }
/**
* Get the login username to be used by the controller.
*
* @return string
*/
public function username()
{
return 'user';
}
/** /**
* Determine if the user is logging in using an email or username,. * Determine if the user is logging in using an email or username,.
* *

View File

@ -51,7 +51,7 @@ class NestDeletionService
{ {
$count = $this->serverRepository->findCountWhere([['nest_id', '=', $nest]]); $count = $this->serverRepository->findCountWhere([['nest_id', '=', $nest]]);
if ($count > 0) { if ($count > 0) {
throw new HasActiveServersException(trans('exceptions.service.delete_has_servers')); throw new HasActiveServersException(trans('exceptions.nest.delete_has_servers'));
} }
return $this->repository->delete($nest); return $this->repository->delete($nest);

View File

@ -12,7 +12,7 @@ return [
| |
*/ */
'lockout' => [ 'lockout' => [
'time' => 120, 'time' => 2,
'attempts' => 3, 'attempts' => 3,
], ],

View File

@ -106,7 +106,7 @@
</div> </div>
<div class="box-body"> <div class="box-body">
<div class="row"> <div class="row">
<div class="form-group col-xs-12"> <div class="form-group col-md-6">
<label for="pDaemonBase" class="form-label">Daemon Server File Directory</label> <label for="pDaemonBase" class="form-label">Daemon Server File Directory</label>
<input type="text" name="daemonBase" id="pDaemonBase" class="form-control" value="/srv/daemon-data" /> <input type="text" name="daemonBase" id="pDaemonBase" class="form-control" value="/srv/daemon-data" />
<p class="text-muted small">Enter the directory where server files should be stored. <strong>If you use OVH you should check your partition scheme. You may need to use <code>/home/daemon-data</code> to have enough space.</strong></p> <p class="text-muted small">Enter the directory where server files should be stored. <strong>If you use OVH you should check your partition scheme. You may need to use <code>/home/daemon-data</code> to have enough space.</strong></p>

View File

@ -141,7 +141,7 @@
<td data-identifier="name" data-name="{{ rawurlencode($file['entry']) }}" data-path="@if($file['directory'] !== ''){{ rawurlencode($file['directory']) }}@endif/"> <td data-identifier="name" data-name="{{ rawurlencode($file['entry']) }}" data-path="@if($file['directory'] !== ''){{ rawurlencode($file['directory']) }}@endif/">
@if(in_array($file['mime'], $editableMime)) @if(in_array($file['mime'], $editableMime))
@can('edit-files', $server) @can('edit-files', $server)
<a href="/server/{{ $server->uuidShort }}/files/edit/@if($file['directory'] !== ''){{ rawurlencode($file['directory']) }}/@endif{{ rawurlencode($file['entry']) }}" class="edit_file">{{ $file['entry'] }}</a> <a href="/server/{{ $server->uuidShort }}/files/edit/@if($file['directory'] !== ''){{ $file['directory'] }}/@endif{{ $file['entry'] }}" class="edit_file">{{ $file['entry'] }}</a>
@else @else
{{ $file['entry'] }} {{ $file['entry'] }}
@endcan @endcan

View File

@ -73,7 +73,7 @@ class NestDeletionServiceTest extends TestCase
$this->service->handle(1); $this->service->handle(1);
} catch (PterodactylException $exception) { } catch (PterodactylException $exception) {
$this->assertInstanceOf(HasActiveServersException::class, $exception); $this->assertInstanceOf(HasActiveServersException::class, $exception);
$this->assertEquals(trans('exceptions.service.delete_has_servers'), $exception->getMessage()); $this->assertEquals(trans('exceptions.nest.delete_has_servers'), $exception->getMessage());
} }
} }