Name

global.PwdAjaxWFRequestProcessorDESKTOP

Description

Ajax Request handler for workflow related tasks for Password Reset application.

Script

/*
* Class is a Ajax processor which handles password reset workflow related functionality.
* This processed handles only Windows Desktop Application calls!
*/
var PwdAjaxWFRequestProcessorDESKTOP = Class.create();
PwdAjaxWFRequestProcessorDESKTOP.prototype = Object.extendsObject(PwdAjaxWFRequestProcessor, {

  /**
   * OVERRIDE FOR THE WINDOWS DESKTOP APPLICATION:
   * This function validates the new password complexity, before proeeding to the parent (super) implementation of startWorkflow.
   */
  startWorkflow: function() {

      var requestId = this.getParameter("sysparam_request_id");
      var newPasswd = this.getParameter("sysparam_new_password");

      // check the security before anything else.
      // If any violation is found, then just return.
      if (!this._validateSecurity()) {
          this._setResponseMessage('failure', gs.getMessage("Unauthorized access"), requestId);
          return;
      }

      var grRequest = new GlideRecord('pwd_reset_request');
      if (!grRequest.get(requestId)) {
          this._setResponseMessage('failure', gs.getMessage("Cannot read request"), requestId); // Ask Roy for better message
          return;
      }

      // Validate new passsword complexity if not auto gen:
      var autoGenPwd = grRequest.process.auto_gen_password.toString() == "true";
      if (!autoGenPwd) {
          var processId = grRequest.process;
          var enablePasswordPolicy = new SNC.PwdCredentialStoreManager().getEnablePasswordPolicy(processId);
          if (enablePasswordPolicy) {
              var credMgr = new SNC.PwdCredentialStoreManager();
              var passwordPolicyId = credMgr.getPasswordPolicyId(processId);
              var jsonResponse = SNC.PasswordPolicyEvaluator.isValidPwdPerPolicyWithMessage(newPasswd, passwordPolicyId, grRequest.user.user_name);
              var validationResponse = JSON.parse(jsonResponse);
              if (validationResponse.success != true) {
                  this._setResponseMessage('warning', gs.getMessage("Invalid password - {0}", validationResponse.message), requestId);
                  return;
              }
          } else {
              var isPwdValid = new SNC.PwdCredentialStoreManager().evaluatePasswordRuleAdvance(processId, newPasswd, requestId);
              if (isPwdValid != "success") {
                  // warning does not take user to failure page
                  this._setResponseMessage('warning', gs.getMessage("New password does not meet criteria"), requestId);
                  return;
              }
          }
      }

      // Call super function:
      PwdAjaxWFRequestProcessor.prototype.startWorkflow.call(this);
  },

  type: PwdAjaxWFRequestProcessorDESKTOP
});

Sys ID

c1be018b531222004acce17de2dc344e

Offical Documentation

Official Docs: