Retrieve password

Retrieve password

An inconsistency was observed when trying to reset the password using the "app_retrieve_pswd" application.
The correction was made for new modules, created from release 9.10.001.

For modules created in previous releases that use this option, we must make a small change to the app_retrieve_pswd application code, check out the tutorial below.
This tutorial covers security modules created before release 9.10.001 and that use the Send email with a link to generate new password option

1- Open the app_retrieve_pswd application

By default, the prefix of security applications is app_ and the "security" folder, so, with scriptcase open, it is possible to locate the application:
The prefix and folder may have been changed during module generation.





2- Access the send_act method

Access the Programming block, in the PHP Methods folder select the send_act method.


3- Add the code

In old modules, the code for this event looks like this:
  1. $act_code = act_code();


  2. $sql = "UPDATE 
  3. sec_1users
  4.     SET
  5.     activation_code = '". $act_code ."'
  6.     WHERE
  7.         login = '". [usr_login] ."'";

  8. sc_exec_sql($sql);

  9. send_mail_message({lang_send_act_code}
  10.                    . "<br/> <a href='http://". $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']. "?act_code=" . $act_code ."'> http://".$_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']. "?act_code=" . $act_code ." </a>");
Below $act_code = act_code(); add the following code: $act_code = substr($act_code, 0, 32);

The code should look like this:
  1. $act_code = act_code();
  2. $act_code = substr($act_code, 0, 32);

  3. $sql = "UPDATE 
  4. sec_1users
  5.     SET
  6.     activation_code = '". $act_code ."'
  7.     WHERE
  8.         login = '". [usr_login] ."'";

  9. sc_exec_sql($sql);

  10. send_mail_message({lang_send_act_code}
  11.                    . "<br/> <a href='http://". $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']. "?act_code=" . $act_code ."'> http://".$_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']. "?act_code=" . $act_code ." </a>");