Skip to content

Commit 591bd05

Browse files
author
dante
committed
Validation of 'data' connection
1 parent 8ae3092 commit 591bd05

5 files changed

Lines changed: 76 additions & 2 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace ProcessMaker\Http\Controllers;
4+
5+
use Carbon\Carbon;
6+
use Illuminate\Support\Facades\Request;
7+
use ProcessMaker\Events\ScreenBuilderStarting;
8+
use ProcessMaker\Managers\ScreenBuilderManager;
9+
use ProcessMaker\Models\Notification;
10+
use ProcessMaker\Models\ProcessRequestToken;
11+
use ProcessMaker\Traits\SearchAutocompleteTrait;
12+
13+
class UnavailableController extends Controller
14+
{
15+
16+
public function show()
17+
{
18+
return view('errors.unavailable');
19+
}
20+
}

‎ProcessMaker/Http/Kernel.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class Kernel extends HttpKernel
6464
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
6565
'sanitize' => \ProcessMaker\Http\Middleware\SanitizeInput::class,
6666
'setlocale' => \ProcessMaker\Http\Middleware\SetLocale::class,
67-
'setskin' => \ProcessMaker\Http\Middleware\SetSkin::class
67+
'setskin' => \ProcessMaker\Http\Middleware\SetSkin::class,
68+
'external.connection' => \ProcessMaker\Http\Middleware\ValidateExternalConnection::class
6869
];
6970
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
namespace ProcessMaker\Http\Middleware;
3+
4+
use Closure;
5+
use Illuminate\Http\Request;
6+
use Illuminate\Support\Facades\DB;
7+
8+
class ValidateExternalConnection
9+
{
10+
/**
11+
* The names of the attributes that should not be trimmed.
12+
*
13+
* @var array
14+
*/
15+
protected $except = [
16+
'password',
17+
'password_confirmation',
18+
];
19+
20+
public function handle(Request $request, Closure $next)
21+
{
22+
try {
23+
DB::connection('data')->getPdo();
24+
}
25+
catch (\Exception $e) {
26+
return redirect('/unavailable');
27+
}
28+
29+
return $next($request);
30+
}
31+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@extends('layouts.layout')
2+
3+
@section('title')
4+
{{__('Server Error - ProcessMaker')}}
5+
@endsection
6+
7+
@section('sidebar')
8+
@include('layouts.sidebar', ['sidebar'=> Menu::get('sidebar_designer')])
9+
@endsection
10+
11+
@section('content')
12+
<div class="container mr-5 mt-5">
13+
<img class="ml-5" src="/img/robot.png"/>
14+
<h1>{{__('Server Error')}}</h1>
15+
<p>{{__('One of the data sources in unavailable. Contact with your system administrator.')}}</p>
16+
</div>
17+
@endsection
18+

‎routes/web.php‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use ProcessMaker\Http\Controllers\Api\Requests\RequestsController;
44

5-
Route::group(['middleware' => ['auth', 'sanitize']], function () {
5+
Route::group(['middleware' => ['auth', 'sanitize', 'external.connection']], function () {
66

77
// Routes related to Authentication (password reset, etc)
88
// Auth::routes();
@@ -103,3 +103,7 @@
103103
$this->get('password/success', function () {
104104
return view('auth.passwords.success', ['title' => __('Password Reset')]);
105105
})->name('password-success');
106+
107+
108+
$this->get('/unavailable', 'UnavailableController@show')->name('error.unavailable');
109+

0 commit comments

Comments
 (0)