context was not found error on APPID @ IBM Cloud while new user signup

58 Views Asked by At

I'm trying to signup a new user, when creating a User it will send a mail to user to complete signup, user clicks on verify button in mail and it redirects to ActivateAccount Page that asks user to fill in password. Below is the url where appid redirects to when click on verify button in mail :

http://localhost:3000/#/changepassword?language=en&context=ZPCMgRf6_PgknrpZEwKkieo5Dq07MxeK

User clicks on submit it will send context and newPassword as formData to api and while calling api I'm getting this error:

{ "errorCode": 404, "errorMessage": "context was not found" }

Below is the code I wrote to handle change password :

    const SelfServiceManager = require("./lib/appid-sdk").SelfServiceManager;
    let selfServiceManager = new SelfServiceManager({
        iamApiKey: config.apikey,
        managementUrl: config.managementUrl 
    });

    routerAPI.post("/changePassword", function(req, res) {
      let uuid
      let language = req.query.language || "en"
    
      // Return UUID and a Success Flag if verification link is valid
      selfServiceManager.getSignUpConfirmationResult(req.query.context).then(function (response) 
  {
        if (response && response.success) {
          logger.debug('sign up result - success');
          console.log(" Print uuid :::: ", response.uuid)
          uuid = response.uuid
          // Check user details when user is verified, pass uuid as input
                selfServiceManager.getUserDetails(response.uuid).then(function (user) {
            if (user.emails[0].value != "" || user.emails[0].value != undefined) {
              // User is verified and its eligible to change password.
              console.log(" **** Print user info :::: ", )
              logger.info("User is verified, Proceeding to password change ...")
              // API to set new user password
              selfServiceManager.setUserNewPassword(uuid,req.query.newPassword).then(function (response) {
                logger.debug("Password reset successfully")
                res.json({ code: 200, message: "Password change successfully" });
              })
            } else {
              // User is not verified and not eligible to change the password.
              logger.debug("User not eligible to change password")
              throw new Error ("User not eligible to change password")
            }
          })
            }
      }).catch((err) => {
       logger.error(err)
       console.log(err)
       return errorResponse(res, err, tagName);
    })
    })

I'm new to APPID and NodeJS. I have done APPID setup using NodeJS SDK.

Please let me know if you need more info!!

Any Help Appreciated ...... Thanks!!

0

There are 0 best solutions below