Hi,
I'd like to know how the process of connection work in php code.
I'd like to make a second way to connect users. I've made an sso-like in my applications and i would like to make a link to pass through the connection process with the 'Id' of the user. Some thing like:
http://localhost/projectoria/login.php?id=4 to connect the user who have the Id=4 in table 'user' (in reality I use the Id with sha1 encryption to don't give clear Id in url).
Thanks.
I find a solution. I've change the /tool/loginCheck.php file.
My projectoria application is on url : http://localhost/projectoria
I use another application on url http://localhost/cms. In this application when one user is connected he can click on a link wich contain 2 parameters : first is "change=true" and second is "changeid=xxx" xxx is the user id in table user of database of projectoria. This id is crypted by sha1.
So i change loginCheck like that:
$change="";
$changeid="";
$login="";
$password="";
if (array_key_exists('login',$_POST)) {
$login=$_POST['login'];
}
if (array_key_exists('password',$_POST)) {
$password=$_POST['password'];
}
if (array_key_exists('change',$_GET)) {
$change=$_GET['change'];
}
if (array_key_exists('changeid',$_GET)) {
$changeid=$_GET['changeid'];
}
if ($login=="" && $change != "true") {
loginError();
}
if ($password=="" && $change != "true") {
loginError();
}
$obj=new User();
if($change == "true"){
$users=$obj->getSqlElementsFromCriteria(false,false,'sha1(id)=''.$changeid.''');
}else{
$crit=array('name'=>$login, 'password'=>md5($password));
$users=$obj->getSqlElementsFromCriteria($crit,true);
}
.......
function loginOk ($user) {
global $login;
global $change;
$_SESSION['user']=$user;
$crit=array();
$crit['idUser']=$user->id;
$crit['idProject']=null;
$obj=new Parameter();
$objList=$obj->getSqlElementsFromCriteria($crit,false);
foreach($objList as $obj) {
if ($obj->parameterCode=='lang') {
$_SESSION['currentLocale']=$obj->parameterValue;
$i18nMessages=null;
} else if ($obj->parameterCode=='defaultProject') {
$prj=new Project($obj->parameterValue);
if ($prj->name!=null and $prj->name!='') {
$_SESSION['project']=$obj->parameterValue;
} else {
$_SESSION['project']='*';
}
} else {
$_SESSION[$obj->parameterCode]=$obj->parameterValue;
}
}
if($change == "true"){
header("Location: http://localhost/projectori a");
}
echo '
echo '
';
echo '';
traceLog("NEW CONNECTED USER '" . $login . "'");
}