lib/controllers/change-password.js
function (form) {
              var viewData = {
                form: form,
                organization: req.organization
              };

              if (form.data.password !== form.data.passwordAgain) {
                viewData.error = 'Passwords do not match.';
                return helpers.render(req, res, view, viewData);
              }

              result.password = form.data.password;

              return resetPasswordWithRecoveryToken(client, result, form.data.password, function (err) {
                if (err) {
                  logger.info('A user attempted to reset their password, but the password change itself failed.');
                  err = oktaErrorTransformer(err);
                  viewData.error = err.userMessage;
                  return helpers.render(req, res, view, viewData);
                }

                if (config.web.changePassword.autoLogin) {
                  var options = {
                    username: result.email,
                    password: result.password
                  };

                  if (req.organization) {
                    options.accountStore = req.organization.href;
                  }

                  return helpers.authenticate(options, req, res, function (err) {
                    if (err) {
                      viewData.error = err.userMessage;
                      return helpers.render(req, res, view, viewData);
                    }

                    res.redirect(config.web.login.nextUri);
                  });
                }

                res.redirect(config.web.changePassword.nextUri);
              });
            }
function (form) {
              var viewData = {
                form: form,
                organization: req.organization
              };

              if (form.data.password !== form.data.passwordAgain) {
                viewData.error = 'Passwords do not match.';
                return helpers.render(req, res, view, viewData);
              }

              result.password = form.data.password;

              return resetPasswordWithRecoveryToken(client, result, form.data.password, function (err) {
                if (err) {
                  logger.info('A user attempted to reset their password, but the password change itself failed.');
                  err = oktaErrorTransformer(err);
                  viewData.error = err.userMessage;
                  return helpers.render(req, res, view, viewData);
                }

                if (config.web.changePassword.autoLogin) {
                  var options = {
                    username: result.email,
                    password: result.password
                  };

                  if (req.organization) {
                    options.accountStore = req.organization.href;
                  }

                  return helpers.authenticate(options, req, res, function (err) {
                    if (err) {
                      viewData.error = err.userMessage;
                      return helpers.render(req, res, view, viewData);
                    }

                    res.redirect(config.web.login.nextUri);
                  });
                }

                res.redirect(config.web.changePassword.nextUri);
              });
            }
function ( form ) { var viewData = { form : form , organization : req . organization } ; if ( form . data . password !== form . data . passwordAgain ) { viewData . error = 'Passwords do not match.' ; return helpers . render ( req , res , view , viewData ) ; } result . password = form . data . password ; return resetPasswordWithRecoveryToken ( client , result , form . data . password , function ( err ) { if ( err ) { logger . info ( 'A user attempted to reset their password, but the password change itself failed.' ) ; err = oktaErrorTransformer ( err ) ; viewData . error = err . userMessage ; return helpers . render ( req , res , view , viewData ) ; } if ( config . web . changePassword . autoLogin ) { var options = { username : result . email , password : result . password } ; if ( req . organization ) { options . accountStore = req . organization . href ; } return helpers . authenticate ( options , req , res , function ( err ) { if ( err ) { viewData . error = err . userMessage ; return helpers . render ( req , res , view , viewData ) ; } res . redirect ( config . web . login . nextUri ) ; } ) ; } res . redirect ( config . web . changePassword . nextUri ) ; } ) ; }
If we get here, it means the user is submitting a password change request, so we should attempt to change the user's password.
If we get here it means the user is submitting a password change request so we should attempt to change the user s password .