Skip to content

Commit

Permalink
fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrián Pardellas Blunier committed Jan 29, 2016
1 parent 2161c9b commit 82c4c64
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
17 changes: 9 additions & 8 deletions lang/en/messages.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

return [
'toogle_navigation' => 'Toggle navigation',
'signout' => 'Sign out',
'validation_error_title' => 'Validation error',
'login_message' => 'Sign in to start your session',
'login_email_input' => 'Email',
'login_password_input' => 'Password',
'login_remember_input' => 'Remember me',
'login_submit_button' => 'Sign in'
'toogle_navigation' => 'Toggle navigation',
'signout' => 'Sign out',
'validation_error_title' => 'Validation error',
'login_message' => 'Sign in to start your session',
'login_email_input' => 'Email',
'login_password_input' => 'Password',
'login_remember_input' => 'Remember me',
'login_submit_button' => 'Sign in',
'login_authorization_missing' => 'Your user is not authorized to access this section',
];
16 changes: 15 additions & 1 deletion src/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php
namespace Anavel\Foundation\Http\Middleware;

use Closure;
use Illuminate\Contracts\Auth\Guard;
use Anavel\Foundation\Contracts\Authenticable;
use Closure;
use Exception;

class Authenticate
{
Expand Down Expand Up @@ -42,6 +44,18 @@ public function handle($request, Closure $next)
}
}

if (! $this->auth->user() instanceof Authenticable) {
throw new Exception('The user model must implement the ' . Authenticable::class . ' contract.');
}

if (! $this->auth->user()->isAnavelAuthorized()) {
return redirect()
->guest(route('anavel.login'))
->withErrors([
'user' => trans('anavel::messages.login_authorization_missing')
]);
}

return $next($request);
}
}

0 comments on commit 82c4c64

Please sign in to comment.