php - Display authenticated users on non-secure (anonymous) routes -
i use php , silex build web app , implemented basic authentication via securityserviceprovider
this:
$app->register(new silex\provider\securityserviceprovider(), array( 'security.firewalls' => array( 'private' => array( 'remember_me' => array( 'key' => $config['secret_key'], 'lifetime' => $config['remember_me_duration'], ), 'pattern' => '^/admin', 'form' => array('login_path' => '/login', 'check_path' => '/admin/login_check'), 'logout' => array('logout_path' => '/admin/logout'), 'users' => $app->share(function () use ($app) { // ... }), ), 'public' => array( 'pattern' => '^/$', 'anonymous' => true, ), 'login' => array( 'pattern' => '^/login$', 'anonymous' => true, ), ), ));
as can see /admin
paths secured, there can use $app['security']->gettoken()->getuser();
actual user authenticated , display logged in $username, if on /login
or /
routes user anon.
if i'm authenticated.
how can authenticated user, if there one, otherwise anon.
string, on /
, /login
routes in order display message like: logged in $username ?
i tried use is_granted('is_authenticated_fully'
function in twig templates check if user authenticated, on /login
, /
returns false (even if i'm authenticated) since anonymous user takes precedence on authenticated ones, no success here.
everything must under same firewall , have use access control.
Comments
Post a Comment