Advertisement:

Author Topic: integrate_validate_login hook problems  (Read 3454 times)

Offline alraben

  • Semi-Newbie
  • *
  • Posts: 22
integrate_validate_login hook problems
« on: November 19, 2008, 08:03:54 AM »
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






Offline Oldiesmann

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,882
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • https://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: integrate_validate_login hook problems
« Reply #1 on: November 19, 2008, 11:23:20 AM »
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
Cincy Space - now open!

Offline alraben

  • Semi-Newbie
  • *
  • Posts: 22
Re: integrate_validate_login hook problems
« Reply #2 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.

Offline Eliana Tamerin

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,611
  • Gender: Female
Re: integrate_validate_login hook problems
« Reply #3 on: December 25, 2008, 09:26:47 PM »
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!

Offline PeeaichpeeBB

  • Semi-Newbie
  • *
  • Posts: 70
Re: integrate_validate_login hook problems
« Reply #4 on: December 26, 2008, 05:44:01 AM »
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.