dj.drezyna Napisano Kwiecień 28, 2013 Zgłoś Share Napisano Kwiecień 28, 2013 Problem jak w temacie. Załączam poniżej pełny kod. Kod AppControllera class AppController extends Controller { public $helpers = array('Html','MojHtml','Opcje1'); public $components = array( 'Session', 'Auth' => array( 'loginRedirect' => array('controller'=>'Profil','action'=>'index'), 'logoutRedirect' => array('controller'=>'Start','action'=>'index'), 'autheticate' => array( 'Blowfish' => array( 'fields' => array('username'=>'login','password'=>'haslo'), 'userModel' => 'Profil' ) ), ) ); } //Kod Kontrolera Profil App::uses('Security','Utility'); class ProfilController extends AppController { public $uses = array('Profil'); public function beforeFilter() { parent::beforeFilter(); $this->Auth->allow('dolacz','zaloguj'); } public function zaloguj() { if ($this->request->is('post')) { //$this->request->data['Profil']['haslo'] = Security::hash($this->request->data['Profil']['haslo'],'blowfish'); if ($this->Auth->login()) { return $this->redirect($this->Auth->redirectUrl()); } else { $this->Session->setFlash(__('Nieprawidłowe hasło lub login!')); } } } public function wyloguj() { $this->redirect($this->Auth->logout()); } } //Kod Modelu Profil App::uses('AppModel','Model'); App::uses('Security','Utility'); class Profil extends AppModel { public $name = 'Profil'; public $useTable = 'uzytk'; public $validate = array( 'login' => array( 'required' => array( 'rule' => array('notEmpty'), 'message' => 'Login jest polem wymaganym!' ) ), 'haslo' => array( 'required' => array( 'rule' => array('notEmpty'), 'message' => 'Hasło jest polem wymaganym!' ) )/*, 'mejl' => array( 'required' => array( 'rule' => array('email'), 'message' => 'Mejl jest polem wymaganym!' ) )*/ ); public function beforeSave($options = array()) { if (isset($this->data['Profil']['haslo'])) { $this->data['Profil']['haslo'] = Security::hash($this->data['Profil']['haslo'],'blowfish'); } $this->data['Profil']['status'] = 1; return true; } } No na wszystkich możliwych miejscach sprawdzałem ten kod tak jak podaje ichże książka kucharska i w ogóle na innych wątkach poświęconych temu promlemowi i mi się wydaje że niczego nie zrobiłem źle ale dlaczego nie działa to nie wiem dlatego byłbym bardzo wdzięczny jeżeli ktoś pomoże. Dzięki P.S. Kod widoku: <div> <p class="naglowek">Logowanie</p> <?php echo $this->Form->create('Profil'); echo $this->Form->input('login'); echo $this->Form->input('haslo'); echo $this->Form->end(__('Zaloguj')); ?> </div> Galeria przyrodnicza http://fotokrajobrazy.warmia.pl Link do komentarza Udostępnij na innych stronach More sharing options...
Booleeks Napisano Listopad 20, 2015 Zgłoś Share Napisano Listopad 20, 2015 mi się wydaje że zmienna ta passwort czyli create() powinna być w innym pliku dodana + do tego jakiś input do poczty i powinno działać. Link do komentarza Udostępnij na innych stronach More sharing options...
Polecane posty
Zarchiwizowany
Ten temat jest archiwizowany i nie można dodawać nowych odpowiedzi.