Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update AuthServiceProvider.php

  • Loading branch information...
commit 3a4802d5afafbe0463a07c3add67a2c22a7ac0d3 1 parent 11eb1af
@vslinko vslinko authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 AuthServiceProvider.php
View
8 AuthServiceProvider.php
@@ -11,9 +11,13 @@ class AuthServiceProvider implements ServiceProviderInterface
public function register(Application $app)
{
$app->before(function (Request $request) use ($app) {
- $app['user'] = $app['session']->get('auth_session', false);
+ $whitelist = isset($app['auth.whitelist']) ? $app['auth.whitelist'] : array('127.0.0.1');
+ $allowed = in_array($request->getClientIp(), $whitelist);
- if (!in_array($request->attributes->get('_route'), array('login_new', 'login')) && !$app['user']) {
+ $fallbackUser = $allowed ? array('username' => 'anon.') : false;
+ $app['user'] = $app['session']->get('auth_session', $fallbackUser);
+
+ if (!$allowed && !in_array($request->attributes->get('_route'), array('login_new', 'login')) && !$app['user']) {
return $app->redirect($app['url_generator']->generate('login_new'));
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.