integrate_validate_login hook problems

Started by alraben, November 19, 2008, 08:03:54 AM

Previous topic - Next topic

alraben

Hi,

I have the following code in the integrate.php script:

//define the integration functions
define('SMF_INTEGRATION_SETTINGS', serialize(array(
   //'integrate_pre_include' => 'integrate.php',
   'integrate_change_email' => 'change_email_function',
   'integrate_change_member_data' => 'change_member_data_function',
   'integrate_reset_pass' => 'reset_pass_function',
   'integrate_exit' => 'exit_function',
   'integrate_logout' => 'logout_function',
   'integrate_outgoing_email' => 'outgoing_email_function',
   'integrate_login' => 'login_function',
   'integrate_validate_login' => 'validate_login_function',
   'integrate_redirect' => 'redirect_function',
   'integrate_delete_member' => 'delete_member_function',
   'integrate_register' => 'register_function',
   'integrate_pre_load' => 'pre_load_function',
   'integrate_whos_online' => 'whos_online_function',
)));

function validate_login_function ($user, $password, $cookieTime)
   {
      //Comprobar si el usuario existe en smf_members. Si existe le damos paso.
      //Si no existe, comprobamos que esté en la base de datos del gestor. Si existe lo insertamos en smf_members y le damos paso.
      //Si no existe, no le damos paso.
   
       //echo "$user<br />";
      //echo "$password<br />";
      //echo "$cookieTime";
      
      //Conexion con la BD.
      $link = mysql_connect('127.0.0.1', 'user', 'password');
      $db_selected = mysql_select_db('database', $link);
      //      
      
      
      //Comprobamos que el usuario no esta en SMF.
      $query = "select * from smf_members where member_name='$user';";
      $result = mysql_query($query);
      
      
      
      if (mysql_num_rows($result)==0)       
      {//if
         //Insertamos el usuario en SMF
         $pass= sha1(strtolower($user) . $password);         
         $query="insert into smf_members(member_name,id_group,passwd,email_address) values('$user',0,'$pass','$user')";
         $result = mysql_query($query);         
      }//if
            
   }

integrate.php script is included in index.php after Settings.php.

Well, like u can see I want to register automatically, all users who log in in the SMF forum. If the user exists, I dont make the  insert to smf_members ... If not exists I make the insert to the smf_members table.

Well the problem is with the password. The system register good the user in the table but says that the password is incorrect ...

What's wrong in that code?

Thanks for all.

Alvaro






Oldiesmann

The password is already hashed at login for security reasons, so you will just need to insert whatever password SMF gives you into the database.
Michael Eshom
Christian Metal Fans

alraben

Ok, thanks!!

The problem was solved but ... now I have another problem, if a user log into my SMF, now his/her username and password is saved perfectly in smf_members table ok?, but he/she must to relogin to login into the system ... why? Why can I do all automatically:

1) the register into smf_member
2) the access to the system.

I've hope explain clearly.

Thanks.

Eliana Tamerin

Is the original topic solved? If so, could this be marked solved? To do so, just click the Topic Solved link below the bottom linktree.

If you have any separate problems, I'd suggest starting a new topic, to keep things organized. And you may get better support than to continue to use this topic, which appears to be solved from the looks of it.
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

PeeaichpeeBB

Quote from: alraben on November 19, 2008, 04:32:21 PM
Ok, thanks!!

The problem was solved but ... now I have another problem, if a user log into my SMF, now his/her username and password is saved perfectly in smf_members table ok?, but he/she must to relogin to login into the system ... why? Why can I do all automatically:

1) the register into smf_member
2) the access to the system.

I've hope explain clearly.

Thanks.

there's a little workflow bug in the way that process runs.
To avoid it, dont use it!

Create your own login form and customLogin.php and post to that!
Since you are capturing the user credentials, they wont be encrypted in anyway, that way, you can encrypt it the first time in the way that SMF does,
do the look up in the SMF user database,
log in the user.,
set the logged in cookie,
Redirect the user to the appropriate page.

OR (which is what I would do)
When you detect that the user is a NEW USER
simply pop up a screen that explains what is going to happen!

Quote
Welcome new user! -A new account has been automatically created for you!
I will have you login twice to ensure that you are not a robot, and that your new encrypted password is properly stored in the database!

;) not absolutely exactly what happens, but close enough and it keeps the user happy, informed and calm.

Advertisement: