Applies to
SuiteCommerce Advanced | Elbrus
This patch adds a method named sendPasswordRetrievalEmail2(), included in Kilimanjaro and later implementations of SuiteCommerce Advanced. Located in the Commerce API, sendPasswordRetrievalEmail2() generates a password reset email message. For added security, the original login email address for the customer does not appear in the password reset URL generated by this method. Other ecommerce solutions commonly use this secure solution.
To implement this patch, you extend JavaScript functions in the Account and LoginRegister modules and override the login_register_reset_password.tpl template file. For an example of the changes needed for this patch, see EmailAddressPasswordResetURL.zip.
This method replaces the sendPasswordRetrievalEmail() method. However, the deprecated sendPasswordRetrievalEmail() method will continue to operate without change.
To implement this patch, follow each step to extend the functions in the Account.Model.js and LoginRegister.ResetPassword.View.js files, and override the login_register_reset_password.tpl template file.
Step 1: Create and Copy the Required Files
- To extend the functions that require a code change for this patch, create a directory to store your custom modules, for example, create
Modules/extensions. - Open this directory and create the following subdirectories to maintain your customizations.
- Give this directory a name similar to the module being customized. For example, create the following directories:
Modules/extensions/AccountExtension@1.0.0Modules/extensions/LoginRegisterExtension@1.0.0- In the
AccountExtension@X.X.Xdirectory, create aSuiteScriptsubdirectory. In theSuiteScriptsubdirectory, create a JavaScript file. - To follow best practices, name the JavaScript file
Account.Model.Extension.js. - Open this file and extend the
forgotPasswordmethod as shown in the following code snippet:
define(
‘Account.Model.Extension’
, [
‘SC.Model’
, ‘Application’
, ‘Models.Init’
, ‘underscore’
]
, function (
SCModel
, Application
, ModelsInit
, _
)
{
‘use strict’;
_.extend(AccountModelExtension.prototype,
{
forgotPassword: function (email)
{
try
{
// this API method throws an exception if the email doesn’t exist
// ‘The supplied email has not been registered as a customer at our Web store.’
ModelsInit.session.sendPasswordRetrievalEmail2(email);
}
catch (e)
{
var error = Application.processError(e);
// if the customer failed to log in previously
// the password retrieval email is sent but an error is thrown
if (error.errorCode !== ‘ERR_WS_CUSTOMER_LOGIN’)
{
throw e;
}
}
return {
success: true
};
}
});
});
- In the
LoginRegisterExtension@X.X.Xdirectory, create aJavaScriptsubdirectory. In theJavaScriptsubdirectory, create a JavaScript file namedLoginRegister.ResetPassword.View.Extension.js. - Open this file and extend the
function namemethod as shown in the following code snippet:
define(‘LoginRegister.ResetPassword.View.Extension’
, [ ‘SC.Configuration’
, ‘Account.ResetPassword.Model’
, ‘Backbone.FormView’
, ‘Backbone’
, ‘underscore’
]
, function (
Configuration
, AccountResetPasswordModel
, BackboneFormView
, Backbone
, _
)
{
‘use strict’;
_.extend(LoginRegisterResetPasswordViewExtension.prototype,
{
initialize: function ()
{
this.model = new AccountResetPasswordModel();
this.model.set(‘params’, {‘cb’:_.parseUrlOptions(location.search).cb});
this.model.on(‘save’, _.bind(this.showSuccess, this));
BackboneFormView.add(this);
}
});
});
- In the
LoginRegisterExtension@X.X.Xdirectory, create aTemplatessubdirectory. Copy theModules/suitecommerce/LoginRegister@2.3.0/Templates/login_register_reset_password.tpltemplate file into theTemplatesdirectory. - Open
login_register_reset_password.tpland make the following change.
Replace this HTML:
<p class=”login-register-reset-password-description”>
{{translate ‘Enter a new password below’}}
</p>
Step 2. Prepare the Developer Tools for Your Overrides
Create the ns.package.json file for the AccountExtension@X.X.X directory. Add the following code to ns.package.json in the Modules/extensions/Account@X.X.X directory:
{
“gulp”: {
“ssp-libraries”:
“SuiteScript/*.js”
},
}
Create the ns.package.json file for the LoginRegisterExtension@X.X.X directory. Add the following code to ns.package.json in the Modules/extensions/LoginRegister@X.X.X directory:
{
“gulp”: {
“javascript”:
“JavaScript/*.js”
“templates”: [
“JavaScript/*.js”
]
},
“overrides”: {
“suitecommerce/LoginRegister@X.X.X/Templates/login_register_reset_password.tpl” :
Templates/login_register_reset_password.tpl
}
In distro.json, add your custom modules to the modules object.
This ensures that the Gulp tasks include your extension when you deploy. In this example, the extension modules are added at the beginning of the list of modules. However, you can add the modules anywhere in the modules object. The order of precedence in this list does not matter.
{
“name”: “SuiteCommerce Advanced Elbrus”,
“version”: “2.0”,
“buildToolsVersion”: “1.3.0”,
“folders”: {
“modules”: “Modules”,
“suitecommerceModules”: “Modules/suitecommerce”,
“extensionsModules”: “Modules/extensions”,
“thirdPartyModules”: “Modules/third_parties”,
“distribution”: “LocalDistribution”,
“deploy”: “DeployDistribution”
},
“modules”: {
“extensions/AccountExtension”: “X.X.X”,
“extensions/LoginRegisterExtension”: “X.X.X”,
…