Support » Plugin: Simple JWT Login - Login and Register to WordPress using JWT » is that part of the database is the password reset code?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author nicu_m

    (@nicu_m)

    Hello @ezequieldevjs,

    First, you need to call POST /user/reset_password. This will set the user_activation_key in the database.(documentation: https://simplejwtlogin.com/docs/reset-password)

    After that, you need to call PUT /user/reset_password with the code. This call will change the password. (documentation: https://simplejwtlogin.com/docs/change-password).

    The reset code might contain special characters, and I would recommend sending the request parameters in the body, as a JSON. If you send them as query parameters, they are encoded.
    https://simplejwtlogin.com/api-explorer#tag/reset_password

    I will add here, a very simple javascript example for the reset-password flow:

    
    function call(method, endpoint, params) {
       var xhttp = new XMLHttpRequest();
       xhttp.open(method, endpoint, true);
       xhttp.setRequestHeader("Content-type", "application/json;charset=UTF-8");
       xhttp.send(JSON.stringify(params));
    
       return xhttp.responseText;
    }
    
    var siteUrl = 'https://your_site.com/?rest_route=/simple-jwt-login/v1/user/reset_password';
    
    //Send Reset Password code:
    var params = {
       'email' : 'test@simplejwtlogin.com',
    };
    
    call('POST', siteUrl, params);
    
    //Change the password
    params['code']='your_code';
    params['new_password']='your_new_password';
    call('PUT', siteUrl, params);
    
    

    Best regards,
    Nicu.

    Thread Starter ezequieldevjs

    (@ezequieldevjs)

    Thanks for answering!! but I have an error with the code:

    {
        "success": false,
        "data": {
            "message": "Invalid code provided.",
            "errorCode": 62
        }
    }
    var myHeaders = new Headers();
    myHeaders.append("Authorization", "Basic YWRtaW46YWRtaW4=");
    myHeaders.append("Content-Type", "application/json");
    
    var raw = JSON.stringify({
      "email": "pepa@gmail.com"
    });
    
    var requestOptions = {
      method: 'PUT',
      headers: myHeaders,
      body: raw,
      redirect: 'follow'
    };
    
    fetch("http://localhost:8888/curabrochero/?rest_route=/simple-jwt-login/v1/user/reset_password&code=1649426318:$P$B91uVsTshZ04dHoxFSjyotlZxqgZxN0&new_password=123456789", requestOptions)
      .then(response => response.text())
      .then(result => console.log(result))
      .catch(error => console.log('error', error));
    Plugin Author nicu_m

    (@nicu_m)

    Try to remove the code from the fetch url and add it to var raw instead.

    Thread Starter ezequieldevjs

    (@ezequieldevjs)

    I did it but the same thing happens I got an error in the code I’ve been with this for 1 week it’s strange

    var myHeaders = new Headers();
    myHeaders.append("Authorization", "Basic YWRtaW46YWRtaW4=");
    myHeaders.append("Content-Type", "application/json");
    
    var raw = JSON.stringify({
      "email": "pepa@gmail.com",
      "code": "1649433055:$P$BPj.ARCOcAz1CKF.6XoiIyVtb7jZCN",
      "new_password": "12345622233"
    });
    
    var requestOptions = {
      method: 'PUT',
      headers: myHeaders,
      body: raw,
      redirect: 'follow'
    };
    
    fetch("http://localhost:8888/curabrochero/?rest_route=/simple-jwt-login/v1/user/reset_password", requestOptions)
      .then(response => response.text())
      .then(result => console.log(result))
      .catch(error => console.log('error', error));
    {
        "success": false,
        "data": {
            "message": "Invalid code provided.",
            "errorCode": 62
        }
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘is that part of the database is the password reset code?’ is closed to new replies.