1. Kayako Download customers: we will continue to develop and support Kayako Download beyond July 2017, alongside the new Kayako for existing customers.

    Find out more.

  2. The forum you are viewing relates to Kayako Classic. If you signed up or upgraded to the new Kayako (after the 4th July 2016), the information in this thread may not apply to you. You can visit the forums for the new Kayako here.

Lost Password

Discussion in 'Using Kayako Classic' started by Igor Kryltsov, Feb 18, 2012.

  1. Igor Kryltsov

    Igor Kryltsov Established Member

    Hi,

    Does anybody know how I can send 'Lost password' email automatically? Just a standard email Kayako sends.

    I want to replace 'Forgot password' link below login with my application reset password page. This page will check if email belongs to:
    a) prospective client - only in Kayako
    b) my application client

    If b) my page will change both passwords in my application and Kayako (if a user has used support and has an account in Kayako) and user will get a confirmation email from my application only. Kayako password will be changed via API.

    If a) I need to be able to ask Kayako to send email as if a user filled email+captcha on Kayako. Question is how to do it if possible.

    Thank you

    P.S I am trying to achieve this.
     
  2. ad_amin

    ad_amin Established Member

    I'm not sure that I really get what you are trying to do...
    In my application I've left the kayako link and I've modified the kayako source so it calls an external script by a http request which changes user password in my database.
    So kayako does its own stuff - changes password in its database and then calls the script which changes password in mine. It all happens after the user clicks the link in email from kayako - so after submiting a form with a new password field.
     
    Igor Kryltsov likes this.
  3. Igor Kryltsov

    Igor Kryltsov Established Member

    This will work. Never thought about this approach. Thank you. Can you share a piece of code (obviously change your URL in it)? I am sure I can figure it out but this will help heaps. Also - do I need to request open code from Kayako to do it?

    Thank you
     
  4. Igor Kryltsov

    Igor Kryltsov Established Member

    One more thing. I guess you did the same thing inside Change password under Profile, didn't you? Code snippet from that page will be also highly appreciated until your hook handles both cases at once :)
     
  5. ad_amin

    ad_amin Established Member

    Code modification in function ResetSubmit in class.Controller_UserLostPassword.php under __swift/modules/base/client.
    After Kayako check for the password match (about line 370) add:

    $userID = $_SWIFT_UserVerifyHashObject->GetProperty('userid');
    $this->Database->Query("SELECT email FROM " . TABLE_PREFIX . "useremails
    WHERE linktypeid = '$userID'");
    while ($this->Database->NextRecord()) {
    $_email = $this->Database->Record['email'];
    }

    $fp = fsockopen('hostName', 80);

    if ($fp !== false) {

    $vars = array( //these are variables that I pass to my script
    'email' => $_email,
    'pass' => $_POST['password'],
    );
    $content = http_build_query($vars);

    fwrite($fp, "POST /nameOfYourScript.php HTTP/1.1\r\n");
    fwrite($fp, "Host: hostName\r\n");
    fwrite($fp, "Content-Type: application/x-www-form-urlencoded\r\n");
    fwrite($fp, "Content-Length: " . strlen($content) . "\r\n");
    fwrite($fp, "Connection: close\r\n");
    fwrite($fp, "\r\n");

    fwrite($fp, $content);

    while (($line = fgets($fp)) !== false) { //if there was an error I return a string with 'error:' at the beggining in the response from my script so here I do the check if there was an error in the response
    if (strpos($line, 'error:') !== false) {
    $line = str_ireplace('error:', '', $line);
    $this->UserInterface->Error(true, $line);
    $this->Load->Index();
    return false;
    }
    }
    fclose($fp);
    } else {
    $this->UserInterface->Error(true, "Sorry, an error has occured. Please try again later.");
    $this->Load->Index();
    return false;
    }

    Under the profile I actually removed the functionality for updating the profile data by modifying the templates - I've just added a note that if a client needs to change his/her details - they need to do it on my main website :) but if you want to allow users to change their details in Kayako then you can do it just the same way - you only need to find the function in Kayako source that handles profile updating.
     
    Szentmarjay Tibor likes this.
  6. Igor Kryltsov

    Igor Kryltsov Established Member

    Thank you.
     

Share This Page