Fix isAdmin and added 401 template
This commit is contained in:
@@ -6,5 +6,11 @@ return [
|
||||
'title' => 'Die Seite konnte nicht gefunden werden!',
|
||||
'message' => 'Entschuldigung, aber die Seite konnte nicht gefunden werden. Überprüfen Sie die URL und versuchen Sie es erneut.',
|
||||
'link' => 'Zurück zur Startseite',
|
||||
]
|
||||
],
|
||||
'unauthorized' => [
|
||||
'code' => '401',
|
||||
'title' => 'Unauthorized',
|
||||
'message' => 'Sorry, you need admin privileges to see this page.',
|
||||
'link' => 'Return to homepage',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -6,5 +6,11 @@ return [
|
||||
'title' => 'That page went missing!',
|
||||
'message' => 'Sorry, but the page you are looking for has not been found. Check the URL for errors and try again.',
|
||||
'link' => 'Return to homepage',
|
||||
]
|
||||
],
|
||||
'unauthorized' => [
|
||||
'code' => '401',
|
||||
'title' => 'Unauthorized',
|
||||
'message' => 'Sorry, you need admin privileges to see this page.',
|
||||
'link' => 'Return to homepage',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -6,5 +6,11 @@ return [
|
||||
'title' => 'Cette page est manquante !',
|
||||
'message' => 'Désolé, mais la page que vous recherchez est introuvable. Vérifier l\'URL et essayez à nouveau.',
|
||||
'link' => 'Retour à l\'accueil',
|
||||
]
|
||||
],
|
||||
'unauthorized' => [
|
||||
'code' => '401',
|
||||
'title' => 'Unauthorized',
|
||||
'message' => 'Sorry, you need admin privileges to see this page.',
|
||||
'link' => 'Return to homepage',
|
||||
],
|
||||
];
|
||||
|
||||
19
app/views/errors/401.blade.php
Normal file
19
app/views/errors/401.blade.php
Normal file
@@ -0,0 +1,19 @@
|
||||
@extends('layout.error')
|
||||
|
||||
@section('content')
|
||||
<div class="middle-box text-center">
|
||||
<div>
|
||||
<img class="logo" height="65" src="{{ url('img/cachet-logo.svg') }}" alt="Cachet">
|
||||
</div>
|
||||
<h1>{{ trans('errors.unauthorized.code') }}</h1>
|
||||
<h3>{{ trans('errors.unauthorized.title') }}</h3>
|
||||
|
||||
<div class="error-desc">
|
||||
<p>{{ trans('errors.unauthorized.message') }}</p>
|
||||
<br>
|
||||
<p>
|
||||
<a href="/" class="btn btn-default btn-lg">{{ trans('errors.unauthorized.link') }}</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
||||
@@ -22,7 +22,7 @@ class AdminFilter
|
||||
public function filter(Route $route, Request $request)
|
||||
{
|
||||
if (!Auth::check() || (Auth::check() && !Auth::user()->isAdmin)) {
|
||||
return Response::make('Unauthorized', 401);
|
||||
return Response::view('errors.401', ['pageTitle' => trans('errors.unauthorized.title')], 401);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ class User extends Model implements UserInterface, RemindableInterface
|
||||
*/
|
||||
public function getIsAdminAttribute()
|
||||
{
|
||||
return (bool) $this->level;
|
||||
return $this->level == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user