Skip to content

Commit

Permalink
Merge pull request #560 from portabilis/portabilis-patch-2019-04-26
Browse files Browse the repository at this point in the history
Portabilis patch 26/04/2019
  • Loading branch information
edersoares authored Apr 29, 2019
2 parents b398ec6 + 8053208 commit ad9dc0c
Show file tree
Hide file tree
Showing 170 changed files with 8,090 additions and 6,817 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ matrix:

script:
- vendor/bin/phpunit
- php artisan dusk
23 changes: 17 additions & 6 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Exception;
use iEducar\Modules\ErrorTracking\Tracker;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\Request;
use Illuminate\Http\Response;

class Handler extends ExceptionHandler
{
Expand All @@ -30,12 +32,15 @@ class Handler extends ExceptionHandler
/**
* Report or log an exception.
*
* @param \Exception $exception
* @param Exception $exception
*
* @return void
*
* @throws Exception
*/
public function report(Exception $exception)
{
if (config('app.trackerror')) {
if (config('app.trackerror') && $this->shouldReport($exception)) {
app(Tracker::class)->notify($exception, $this->getContext());
}

Expand All @@ -45,19 +50,25 @@ public function report(Exception $exception)
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
* @param Request $request
* @param Exception $exception
*
* @return Response
*/
public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}

/**
* Return context data for the error.
*
* @return array
*/
private function getContext()
{
if (app()->runningInConsole()) {
return null;
return [];
}

return app('request')->all();
Expand Down
9 changes: 8 additions & 1 deletion app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;

class LoginController extends Controller
{
Expand All @@ -30,11 +31,17 @@ class LoginController extends Controller
/**
* Create a new controller instance.
*
* @param Request $request
*
* @return void
*/
public function __construct()
public function __construct(Request $request)
{
$this->middleware('guest')->except('logout');

if (empty($request->query('force'))) {
$this->middleware('ieducar.suspended')->except('login');
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/ResetPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function rules()
protected function validationErrorMessages()
{
return [
'password.required' => 'O campo senha é obritório.',
'password.required' => 'O campo senha é obrigatório.',
'password.confirmed' => 'As senhas não são iguais.',
'password.min' => 'A senha deve conter ao menos 8 caracteres.',
];
Expand Down
16 changes: 1 addition & 15 deletions app/Http/Controllers/LegacyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,13 @@ private function loadLegacyFile($filename)
*
* @return void
*
* @throws HttpResponseException
* @throws HttpException
* @throws Exception
*/
private function loadFileOrAbort($filename)
{
try {
require_once $filename;
return;
} catch (HttpResponseException $exception) {

// Para evitar encerrar a aplicação com `die` ou `exit`, é lançada
// uma exceção do tipo `HttpResponseException` com uma `Response`
// interna que será a resposta devolvida pela aplicação.

throw $exception;

} catch (Exception $exception) {

// A maioria das vezes será pega a Exception neste catch, apenas
Expand All @@ -154,11 +144,7 @@ private function loadFileOrAbort($filename)
);
}

if (config('app.debug')) {
throw $exception;
}

throw new HttpException(500, 'Error in legacy code.', $exception);
throw $exception;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class Kernel extends HttpKernel
'ieducar.menu' => \App\Http\Middleware\Menu::class,
'ieducar.footer' => \App\Http\Middleware\Footer::class,
'ieducar.xssbypass' => \App\Http\Middleware\XssByPass::class,
'ieducar.suspended' => \App\Http\Middleware\Suspended::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];

Expand All @@ -89,5 +90,6 @@ class Kernel extends HttpKernel
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Illuminate\Auth\Middleware\Authorize::class,
\App\Http\Middleware\ChangeAppName::class,
\App\Http\Middleware\Suspended::class,
];
}
6 changes: 3 additions & 3 deletions app/Http/Middleware/ConnectTenantDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public function getTenant(Request $request)
public function getDefaultTenantResolver()
{
return function (Request $request) {
return Str::replaceFirst(
'.' . config('app.default_host'), '', $request->getHost()
);
$host = str_replace('-', '', $request->getHost());

return Str::replaceFirst('.' . config('app.default_host'), '', $host);
};
}

Expand Down
32 changes: 32 additions & 0 deletions app/Http/Middleware/Suspended.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Session;

class Suspended
{
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
$active = Config::get('legacy.config.active_on_ieducar');
$level = Session::get('nivel');

if ($active || $level === 1) {
return $next($request);
}

return new RedirectResponse('/intranet/suspenso.php');
}
}
Loading

0 comments on commit ad9dc0c

Please sign in to comment.