-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy path_sfUserPasswordReset.js
More file actions
31 lines (24 loc) · 937 Bytes
/
_sfUserPasswordReset.js
File metadata and controls
31 lines (24 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'use strict';
// Initialize required modules
const sfdx = require('sfdx-node/parallel');
/**
* @function _sfUserPasswordReset
* @description Attempts to reset the password for the scratchOrg user
*
* @param {Object} environmentDef Represents the already-validated environment details to use when performing the actions
* @returns {Promise} Returns the result of the password-reset attempt
*/
module.exports = (environmentDef) => {
// Initialize local variables
let deployArguments;
// Default the deployment arguments
deployArguments = {
_rejectOnError: true
};
// Set the username to deploy to if it's defined
if (Object.prototype.hasOwnProperty.call(environmentDef, 'sfScratchOrgUsername')) {
deployArguments.targetusername = environmentDef.sfScratchOrgUsername;
}
// Attempt to reset the user's password
return sfdx.force.user.passwordGenerate(deployArguments);
};