Devo registrare gli utenti al forum passando da un altro servizio ed ho preparato uno script che aggiorna la pwd esternamente da PHPBB.
Nei miei test locali funziona tutto perfettamente.
L'operazione è la seguente:
- cambio pwd da script
- esecuzione codice
- update pwd
- test login
In locale è tutto ok, in produzione il codice non riporta errori ma il funzionamento è random nel senso che l'update della tabella USERS e dei campi PWD AVVIENE correttamente ma non viene accettato il LOGIN.
La cosa assurda è che con alcuni utenti funziona e con altri no.
Cosa sto sbagliando?
EDIT: può essere un problema di SESSIONI o cookie? Perchè ho passato le credenziali con cui non mi loggavo ad un altro utente, che invece è riuscito ad accedere.
Stanno succedendo eventi molto "anomali" che mi fanno pensare sia un problema di cookie o sessioni.
EDIT2: ho notato che in modalità INCOGNITO, dopo alcuni CTRL+F5 riesco a loggarmi con le credenziali mentre dalla navigazione normale no.
EDIT3: Il problema sembra presentarsi con Chrome mentre con Firefox sembra funzionare tutto.
Qualche consiglio?
Il codice per l'update è sostanzialmente questo:
Codice: Seleziona tutto
function cambiaPwdMailForum($datiUtente,$mailUtente)
{
define('IN_PHPBB', true);
require_once($phpbb_root_path . 'common.php');
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
$userName = $datiUtente['username'];
$user_pwd = $datiUtente['password'];
$aUser = array// First user we want to update
('new_password' => $user_pwd // Passphrase
,'user_email' => $mailUtente
, 'username' => $userName
, 'user_id' => 2 // User which is about to be updated
);
// Name all table columns to be updated.
$aSql = array
('user_password' => phpbb_hash($aUser['new_password']) // Passwords are hash-stored only
, 'user_passchg' => time() // Consider this a password change
);
// Execute update
$sql = "UPDATE " . USERS_TABLE . " SET " . $db->sql_build_array('UPDATE', $aSql) . " WHERE username = '".$aUser['username']."' AND user_email= '" . $aUser['user_email'] ."'";
$err = $db->sql_query($sql);
}
$azioniSuRighe = $db->sql_affectedrows();
if ($err == false) {
return false;
} else {
return $azioniSuRighe; //true;
}