Skip to content

Commit

Permalink
own 403 implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ph4r05 committed Apr 4, 2017
1 parent 7241e4b commit 47e39eb
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/Http/Controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;

class IndexController extends Controller
Expand All @@ -35,6 +36,10 @@ public function __construct()
*/
public function show()
{
if (Gate::denies('is-user')) {
return abort(403, 'Unauthorized action.');
}

$user = Auth::user();
$loggedIn = Auth::check();
Log::info('Index shown, user: ' . (empty($user) ? "-" : $user->getAuthIdentifierName()) . ' logged in: ' . $loggedIn);
Expand Down
4 changes: 4 additions & 0 deletions app/Http/Controllers/ServiceRegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public function __construct()
*/
public function show()
{
if (Gate::denies('is-user')) {
return abort(403);
}

if (Gate::denies('is-admin')) {
Log::info('Non-admin user editing services');
return redirect()->intended('/');
Expand Down
77 changes: 77 additions & 0 deletions resources/views/errors/403.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Private Space</title>
<link rel="shortcut icon" href="./images/favicon.png" type="image/png" />

<!-- JS -->
<script src="js/app.js"></script>
<script src="js/handlebars-v4.0.6.min.js"></script>

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->

<!-- Styles -->
<link href="css/app.css" rel="stylesheet">
<link href="css/vpnstyle.css" rel="stylesheet">
<link href="css/font-awesome.min.css" rel="stylesheet">

</head>
<body class="enigmabridge">
<div class="container">
<div class="navbar">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="https://enigmabridge.com"></a>
</div>
</div>
</div>

<h1 style="color:#00a7d7">Cloud Private Space</h1>
<h3>403 - Unauthorized</h3>
<p>TPlease connect using your key to enter. Unauthorized access strictly prohibited.
<br/><br/>
</p>

<hr class="separator">
<div class="row privatespace-services">
<div class="col-lg-12">
<div>
<a href="https://enigmabridge.freshdesk.com/solution/categories/19000098261"
class="btn btn-sq btn-warning">
<i class="fa fa-group fa-3x"></i><br/>
Manuals<br>and Support
</a>

<a href="https://enigmabridge.com/spaces" class="btn btn-sq btn-info">
<i class="fa fa-heart fa-3x"></i><br/>
<br>Enigma Bridge
</a>
<a href="https://enigmabridge.freshdesk.com/helpdesk/tickets/new" class="btn btn-sq btn-danger">
<i class="fa fa-envelope-o fa-3x"></i><br/>
<br>Request Help
</a>
</div>
</div>

</div>

<div id="userStats" style="display: none">
<hr class="separator">
<div class="row">
<h3>Private space devices</h3>
<div class="table-responsive">
<div id="statsPlaceholder"></div>
</div>
</div>
</div>
</div>
</body>
</html>

0 comments on commit 47e39eb

Please sign in to comment.