Jump to content

update employee password in module


vinaysaini

Recommended Posts

I wanted to update the password of current employee in back office. Here is my code what I did,

 

 

 

            $passwd_post = $_POST['passwd'];
            $passwd = Tools::encrypt($passwd_post);        
            $eid = $this->context->employee->id;
            $this->updatePassword($passwd,$eid);
 
/* update  password function */
public function updatePassword($passwd,$eid)
   {       
               $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
               UPDATE '._DB_PREFIX_.'employee
               SET passwd = "'.$passwd.'"
               WHERE id_employee = "'.$eid.'"');        
   }
            
 
This code works perfectly fine. But the problem is, Cookie has its own old password $this->context->employee->passwd
 
Because of which as soon as I go to any other page it logs me out after the password has been changed. And I have to login again.  How Can I fix this Any help??????

 

Link to comment
Share on other sites

  • 2 weeks later...

you have to change employee password value stored in cookie

take a look how it looks in authentication function:

 

// Update cookie

$cookie = Context::getContext()->cookie;
$cookie->id_employee = $this->context->employee->id;
$cookie->email = $this->context->employee->email;
$cookie->profile = $this->context->employee->id_profile;
$cookie->passwd = $this->context->employee->passwd;
$cookie->remote_addr = $this->context->employee->remote_addr;
$cookie->write();
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...