Created
July 19, 2011 14:33
-
-
Save richsage/1092555 to your computer and use it in GitHub Desktop.
FOSFacebookBundle woes (updated, using my own provider, same issue)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// assume all generic use statements up here for Controller, RedirectResponse etc | |
class AccessController extends Controller | |
{ | |
/** | |
* Called when a user attempts to sign in with facebook | |
* | |
* @Route("/signin/facebook", name="signin_facebook") | |
* @return \Symfony\Bundle\FrameworkBundle\Controller\Response | |
*/ | |
public function fbSignInAction() | |
{ | |
// Trigger the FB auth | |
$router = $this->get("router"); | |
$triggerURL = $router->generate("signin_facebook_callback"); | |
return new RedirectResponse($triggerURL); | |
} | |
/** | |
* Should be called once FB auth has taken place | |
* and takes the user to the appropriate page | |
* | |
* @Route("/signin/facebook/callback", name="signin_facebook_callback") | |
* @Secure("ROLE_FACEBOOK") | |
* @return \Symfony\Component\HttpFoundation\RedirectResponse | |
*/ | |
public function fbCallbackAction() | |
{ | |
$user = $this->get("security.context")->getToken()->getUser(); | |
$route = $this->getUserDestinationRouteOnLogin($user); // returns eg "dashboard" or "route_name_for_page" | |
return new RedirectResponse($this->get("router")->generate($route)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
security: | |
factories: | |
- "%kernel.root_dir%/../vendor/bundles/FOS/FacebookBundle/Resources/config/security_factories.xml" | |
role_hierarchy: | |
ROLE_ADMIN: ROLE_USER | |
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] | |
providers: | |
my_facebook_provider: | |
id: my.facebook.users | |
firewalls: | |
profiler: | |
pattern: ^/_profiler | |
security: false | |
wdt: | |
pattern: ^/_wdt | |
security: false | |
# Front-end | |
public: | |
pattern: ^/.* | |
anonymous: true | |
logout: true | |
fos_facebook: | |
check_path: /signin/facebook/auth | |
cancel_url: /?fbfail=1 | |
provider: my_facebook_provider | |
access_control: | |
# Front-end paths | |
- { path: ^/my, role: [IS_AUTHENTICATED_FULLY] } | |
- { path: ^/.*, role: [IS_AUTHENTICATED_ANONYMOUSLY] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment