Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Symfony]2 Autnetykacja kody błędów
meron11
post
Post #1





Grupa: Zarejestrowani
Postów: 78
Pomógł: 1
Dołączył: 17.08.2009

Ostrzeżenie: (0%)
-----


Zrobiłem sobie autentykacje, controlel do login forma z dokumentacji symfony:
  1. public function loginAction()
  2. {
  3. // get the login error if there is one
  4. if ($this->get('request')->attributes->has(SecurityContext::AUTHENTICATION_ERROR))
  5. {
  6. $error = $this->get('request')->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
  7. }
  8. else
  9. {
  10. $error = $this->get('request')->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
  11. }
  12.  
  13. return $this->render('cmsAdminBundle:Secured:login.html.twig', array(
  14. // last username entered by the user
  15. 'last_username' => $this->get('request')->getSession()->get(SecurityContext::LAST_USERNAME),
  16. 'error' => $error,
  17. ));
  18. }



Działą tworzy sesje,ale jedna zagadka, zawsze jak wejdę na stronę logowania jest ostatni błąd, czyli np źle wpisałem hasło, wchodzę jeszcze raz wpisujac od nowa url ,błąd tkwi nadal, idize to jakoś "naprawić"?

Ten post edytował meron11 11.11.2011, 14:48:25
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
destroyerr
post
Post #2





Grupa: Zarejestrowani
Postów: 879
Pomógł: 189
Dołączył: 14.06.2006
Skąd: Bytom

Ostrzeżenie: (0%)
-----


Uzależnij wyświetlanie błędów od tego czy żądanie jest GET czy POST. Jeśli to GET to znaczy, że nie został wysłany i powinieneś wyświetlać tylko formularz, bez błędów.
Go to the top of the page
+Quote Post
meron11
post
Post #3





Grupa: Zarejestrowani
Postów: 78
Pomógł: 1
Dołączył: 17.08.2009

Ostrzeżenie: (0%)
-----


  1. $this->get('request')



To nie jest to?

Zrobiłem teraz tak:

  1. $request2 = Request::createFromGlobals();
  2.  
  3. if($request2->getMethod() == "POST"){
  4.  
  5. if ($this->get('request')->attributes->has(SecurityContext::AUTHENTICATION_ERROR))
  6. {
  7. $error = $this->get('request')->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
  8. }
  9. else
  10. {
  11. $error = $this->get('request')->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
  12. }
  13. }
  14. else
  15. {
  16. $error='';
  17. }
  18.  


To wgl błędu nie pokazuje .

Ten post edytował meron11 11.11.2011, 19:19:24
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 05:34