Hi
I changed the login script , so the user logs in with his "user_name" instead of the "email" -which is more logical- and I have a problem.
the login works, and the code is 100% functional I know that because when I write a valid user_name and password it doesn't give the error message, and when I enter an unvalid data it shows the message.
but the problem is it doesnt redirect me to the index page, and if I type the index path in the url it redirects me back to the login page..
there is something missing from the session, I think something needs to be changed in the zend library for it to work because I checked all the scripts in the SI relating to the login and everything is fine .
sorry, my mistake ,, I missed a variable in the query in the login page!!!!!! it wasted over 4 hours of my time !!!!!!
any way here is my login page script
<?php
/* Script: login.php - Login page */
$menu = false;
// we must never forget to start the session
//so config.php works ok without using index.php define browse
define("BROWSE","browse");
Zend_Session::start();
$errorMessage = '';
if (isset($_POST['user']) && isset($_POST['pass'])) {
// ...or configure the instance with setter methods
$authAdapter = new Zend_Auth_Adapter_DbTable($zendDb);
//db stuff
$user_table = 'user';
$user_name = 'user_name';
$user_password = 'password';
$authAdapter->setTableName(TB_PREFIX.$user_table)
->setIdentityColumn($user_name)
->setCredentialColumn($user_password)
->setCredentialTreatment('MD5(?)');
//$userEmail = $_POST['user']; vega
$user_name = $_POST['user'];
$password = $_POST['pass'];
// Set the input credential values (e.g., from a login form)
$authAdapter->setIdentity($user_name)
->setCredential($password);
// Perform the authentication query, saving the result
$result = $authAdapter->authenticate();
if ($result->isValid()) {
Zend_Session::start();
/*
* grab user data from the datbase
*/
$result = $zendDb->fetchRow("
SELECT
u.id, u.user_name, r.name as role_name, u.domain_id
FROM
si_user u, si_user_role r
WHERE
u.user_name = ? AND u.role_id = r.id AND u.enabled = '".ENABLED."'", $user_name
);
/*
* chuck the user details sans password into the Zend_auth session
*/
$authNamespace = new Zend_Session_Namespace('Zend_Auth');
foreach ($result as $key => $value)
{
$authNamespace->$key = $value;
}
header('Location: .');
} else {
$errorMessage = '????, ??? ???????? ?? ???? ?????? ???';//'Sorry, wrong user / password';
}
}
$smarty->assign("errorMessage",$errorMessage);
?>
thanks VeGaTrOn for posting this
from 2010.1 an onwards we are just using email address for the user details
refer http://simpleinvoices.org/demo/index.php?module=user&view=add
but your free to add or use whatever fields you want for whatever purpose
- note - or you could just rename email address in the GUI to login name or similar
cheers
justin
thanks VeGaTrOn
@bmcgonag
- no email vaildation - you can insert whatever you want
- just assumed email is the most universal ID most people have and msot people don;t want another login to remember
cheers
justin
It looks like you're new here. If you want to get involved, click one of these buttons!