Fix isAdmin and added 401 template

This commit is contained in:
Joseph Cohen
2015-01-23 17:06:46 -06:00
parent 787ecde0ea
commit 90c8551010
6 changed files with 42 additions and 5 deletions

View File

@@ -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',
],
];

View File

@@ -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',
],
];

View File

@@ -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',
],
];

View 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

View File

@@ -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);
}
}
}

View File

@@ -133,7 +133,7 @@ class User extends Model implements UserInterface, RemindableInterface
*/
public function getIsAdminAttribute()
{
return (bool) $this->level;
return $this->level == 1;
}
/**