symfony - Authentication access control ROLES -


using symfony2.1 und fosfacebookbundle:

if user typing www.example.com, e.g. user closed browser, want redirect www.example.com/secured if still authenticated.

i can not in indexaction if user authenticated.

my security.yml:

security: encoders:     symfony\component\security\core\user\user: plaintext  role_hierarchy:     role_admin:       role_user     role_super_admin: [role_user, role_admin, role_allowed_to_switch]  providers:     in_memory:         memory:             users:                 user:  { password: userpass, roles: [ 'role_user' ] }                 admin: { password: adminpass, roles: [ 'role_admin' ] }     my_fos_facebook_provider:             id: my.facebook.user                  //how can add here role_user?  firewalls:       //standard thing fosfacebookbundle  access_control:     - { path: ^/, roles: [is_authenticated_anonymously]  }  

my indexaction:

if( $this->container->get('security.context')     ->isgranted('is_authenticated_fully') ){    echo 'asdf'; //this working in secured area www.example.com/secured/ } 

my error message: security context contains no authentication token. 1 possible reason may there no firewall configured url.

in secured area user has no roles. how can change it?

what wrong?

update

namespace frontend\fbaccountbundle\entity;  use doctrine\orm\mapping orm;   /**  * user  *  * @orm\table(name="user")  * @orm\entity  */ class user { /**  * @var integer  *  * @orm\column(name="id", type="bigint", nullable=false)  * @orm\id  * @orm\generatedvalue(strategy="identity")  */ private $id;  /**  * @var integer  *  * @orm\column(name="facebook_id", type="bigint", nullable=false)  */ private $facebookid; /**  * @param array  */ public function setfbdata($fbdata) {     if (isset($fbdata['id'])) {         $this->setfacebookid($fbdata['id']);         $this->addrole('role_facebook');     } } 

security.yml:

services: my.facebook.user:     class: frontend\fbaccountbundle\security\user\provider\facebookprovider     arguments:         facebook: "@fos_facebook.api"         usermanager: "@fos_user.user_manager"         validator: "@validator"         container: "@service_container" 

you need write user provider add role user. covered in fosfacebookbundle documentation. take @ service definition , setfbdata method on user entity near bottom of page. should give solid start.

integration fosuserbundle


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -