मैंने इसे हल किया।
समाधान नहीं है: How to disable redirection after login_check in Symfony 2
और यहाँ कोड है जो मेरी समस्या का हल है:
form_login:
check_path: /access/login_check
login_path:/
use_referer: true
failure_handler: authentication_handler
logout:
path: /access/logout
target:/
success_handler: authentication_handler
और विन्यास के लिए:
<?php
namespace Acme\MainBundle\Handler;
use Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
class AuthenticationHandler implements AuthenticationFailureHandlerInterface, LogoutSuccessHandlerInterface
{
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{
$referer = $request->headers->get('referer');
$request->getSession()->setFlash('error', $exception->getMessage());
return new RedirectResponse($referer);
}
public function onLogoutSuccess(Request $request)
{
$referer = $request->headers->get('referer');
return new RedirectResponse($referer);
}
}
घटनाओं उदाहरण के लिए security.yml में जोड़ने को संभालने के लिए .yml:
services:
authentication_handler:
class: Acme\MainBundle\Handler\AuthenticationHandler
स्रोत
2012-01-30 14:44:30
विफलता पथ केवल लॉगिन प्रॉम्प्ट क्यों नहीं होगा? – JamesHalsall
क्योंकि मैं प्रत्येक उपपृष्ठ से लॉगिन कर सकता हूं। मुझे निर्दिष्ट यूआरएल पर एक लॉगिन फॉर्म नहीं मिला है, इसलिए जब मैं लॉगिन करता हूं तो उपयोगकर्ता को होमपेज पर रीडायरेक्ट नहीं करना चाहता, उदाहरण के लिए किसी अन्य उपयोगकर्ता प्रोफाइल पेज। –