Reputation: 515
I hope to customize authentication links in my sf2 project, I use SonataAdmin SonataUserBundle(backend) and FosuserBundle + HWIOAuthBundle(facebook login), I created a accoutbundle bundle and here is my controller :
class ConnectController extends Controller
{
public function loginAction()
{
//login code
$request = $this->container->get('request');
/* @var $request \Symfony\Component\HttpFoundation\Request */
$session = $request->getSession();
/* @var $session \Symfony\Component\HttpFoundation\Session\Session */
// get the error if any (works with forward and redirect -- see below)
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} elseif (null !== $session && $session->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
$session->remove(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = '';
}
.....
To create my own login page and here is my app/config/routing.yml :
admin:
resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
prefix: /admin
_sonata_admin:
resource: .
type: sonata_admin
prefix: /admin
sonata_user_security:
resource: "@SonataUserBundle/Resources/config/routing/sonata_security_1.xml"
sonata_user_resetting:
resource: "@SonataUserBundle/Resources/config/routing/sonata_resetting_1.xml"
prefix: /resetting
sonata_user_profile:
resource: "@SonataUserBundle/Resources/config/routing/sonata_profile_1.xml"
prefix: /profile
sonata_user_register:
resource: "@SonataUserBundle/Resources/config/routing/sonata_registration_1.xml"
prefix: /register
sonata_user_change_password:
resource: "@SonataUserBundle/Resources/config/routing/sonata_change_password_1.xml"
prefix: /profile
sonata_user:
resource: '@SonataUserBundle/Resources/config/routing/admin_security.xml'
prefix: /admin
#HWIOAuthBundle routes
hwi_oauth_security:
resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
prefix: /login
hwi_oauth_connect:
resource: "@HWIOAuthBundle/Resources/config/routing/connect.xml"
prefix: /login
hwi_oauth_redirect:
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
prefix: /login
facebook_login:
pattern: /login/check-facebook
facebook_connect:
pattern: /login/facebook
account_connect:
pattern: /connect
defaults: { _controller: AcmeAccountBundle:Connect:login } //personalized link does not work
so the problem that link of login page /app_dev.php/login it does not point to "account_connect" but he always go to the sonata user login page,so my question here is how to disable the sonatauserbundle rounting without change anything in my vendor folder?
Upvotes: 0
Views: 1042
Reputation: 1692
Routing always mach with first entry in table. I think the best way to change routing in bundle which is in vendor folder is override part of it.
See here: http://symfony.com/doc/current/cookbook/bundles/override.html
Upvotes: 1