Zend_Auth // "Supplies credential invalid"
Salut à tous,
J'ai un soucis "nouveau" avec Zend_Auth. J'ai ce message d'erreur, alors que je ne crois pas avoir modifier mon code :
Code:
1 2
| array
0 => string 'Supplied credential is invalid.' (length=31) |
Voici le dump (une partie) de l'adapteur :
Code:
1 2 3 4 5 6 7 8 9 10
| protected '_dbSelect' => null
protected '_tableName' => string 'users' (length=5)
protected '_identityColumn' => string 'username' (length=8)
protected '_credentialColumn' => string 'password' (length=8)
protected '_identity' => string 'admin' (length=5)
protected '_credential' => string 'password' (length=8)
protected '_credentialTreatment' => string 'SHA1(CONCAT(?,salt))' (length=20)
protected '_authenticateResultInfo' => null
protected '_resultRow' => null
protected '_ambiguityIdentity' => boolean false |
Le login et pass sont correct, je l'ai ai modifié depuis le code de rob Allen :
Code:
1 2 3
| INSERT INTO users (username, password, salt, role, date_created)
VALUES ('admin', SHA1('passwordce8d96d579d389e783f95b3772785783ea1a9854'),
'ce8d96d579d389e783f95b3772785783ea1a9854', 'administrator', NOW()); |
Je vois pas trop ou est le problème, et dur de trouver des réponses sur le net.
Portions de code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| public function getAuthAdapter($values) {
if (null === $this->_authAdapter) {
$dbAdapter = Zend_Db_Table::getDefaultAdapter();
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
$tableRecord = Zend_Registry::get('config')->tables;
if (isset($tableRecord)) {
$authAdapter->setTableName($tableRecord->users)
->setIdentityColumn('username')
->setCredentialColumn('password')
->setCredentialTreatment('SHA1(CONCAT(?,salt))');
$this->setAuthAdapter($authAdapter);
$this->_authAdapter->setIdentity($values['username']);
$this->_authAdapter->setCredential($values['password']);
}
}
return $this->_authAdapter;
}
...
public function authenticate($credentials) {
$adapter = $this->getAuthAdapter($credentials);
var_dump($adapter);
$auth = $this->getAuth();
$result = $auth->authenticate($adapter);
if ($result->isValid()) {
$user = $adapter->getResultRowObject();
$auth->getStorage()->write($user);
return true;
} else {
$this->errorMessage = $result->getMessages();
}
return false;
}
...
$authentification = new Custom_Auth_Authentication();
if ($authentification->getIdentity()) {
$this->_redirect("/accueil-administration.html");
} else {
$form = new Frontoffice_Form_Login();
$login = $this->getRequest()->getParam('login');
$password = $this->getRequest()->getParam('password');
if ($this->_request->isPost()) {
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData)) {
$authentification = new Custom_Auth_Authentication();
if ($authentification->authenticate($formData)) {
$this->_redirect("/accueil-administration.html");
} else {
throw new Exception(__CLASS__ . ' / ' . __FILE__ . ' / ' . __METHOD__ . ' / ' . __LINE__);
}
} else {
$form->populate($formData);
}
}
$this->view->form = $form;
} |
Une idée?
Merci
F.