Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [Symfony]Formularz logowania do sfGuardPlugin
stirith
post 12.10.2009, 23:51:22
Post #1





Grupa: Zarejestrowani
Postów: 162
Pomógł: 2
Dołączył: 18.01.2008

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


Zainstalowałem plugin sfGuardPlugin, chcę aby na stronie głównej użytkownik miał możliwość zalogowania się, dlatego też skopiowałem kod z sfGuardFormSignin.class.php i stworzyłem nową klasę LoginForm którą umieściłem w lib/form

Kod
<?php

class LoginForm extends sfForm {

  public function configure()
  {
    $this->setWidgets(array(
      'username' => new sfWidgetFormInput(),
      'password' => new sfWidgetFormInput(array('type' => 'password')),
      'remember' => new sfWidgetFormInputCheckbox(),
    ));

    $this->setValidators(array(
      'username' => new sfValidatorString(),
      'password' => new sfValidatorString(),
      'remember' => new sfValidatorBoolean(),
    ));

    $this->validatorSchema->setPostValidator(new sfGuardValidatorUser());

    $this->widgetSchema->setNameFormat('signin[%s]');
  }
}

?>


W module dodałem:

Kod
$this->loginForm = new LoginForm();


template:

Kod
<form action="<?php echo url_for('@sf_guard_signin') ?>" method="post">
  <table>
    <?php echo $loginForm ?>
  </table>

  <input type="submit" value="sign in" />
</form>


I wszystko ładnie się wyświetla jednak po wpisaniu danych wyświetla się błąd:

Kod
csrf token: CSRF attack detected.


Jaki atak wykryty, nie kumam tego...Jak rozwiązać mój problem ?

P.S -> oczywiście po wejściu bezpośrednio /login -> logowanie działa bez problemu

Ten post edytował stirith 12.10.2009, 23:52:32
Go to the top of the page
+Quote Post
grn
post 13.10.2009, 23:09:02
Post #2





Grupa: Zarejestrowani
Postów: 25
Pomógł: 4
Dołączył: 1.06.2009

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


Nie duplikuj kodu. Użyj sfGuardFormSignin, zamiast własnej klasy. U mnie działa bez zarzutu. Błąd ten oznacza, że token CSRF jest zły lub nie został wysłany.

Ten post edytował grn 13.10.2009, 23:10:17
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 Wersja Lo-Fi Aktualny czas: 22.06.2025 - 17:52