N/auth Module for User Credential Management in NetSuite
The N/auth module enables changing NetSuite user email addresses and passwords, ensuring security and account integrity.
The N/auth module allows developers to manage NetSuite user credentials by providing methods to change both the email address and password of the currently logged-in user. This is crucial for maintaining account security and ensuring that users can quickly update their credentials as necessary.
What Methods Are Available in the N/auth Module?
The N/auth module includes the following key methods:
| Member Type | Name | Return Type | Supported Script Types | Description |
|---|---|---|---|---|
| Method | auth.changeEmail(options) | void | Server scripts | Changes the current user's email address. |
| Method | auth.changePassword(options) | void | Server scripts | Changes the current user's password. |
How to Change a User's Email and Password
To change the user's email and password, the following SuiteScript code can be used:
Code Sample
Here’s an example script that changes the current user's NetSuite email and password:
1/**2 * @NApiVersion 2.x3 */4 5require(['N/auth'], function(auth) {6 function changeEmailAndPassword() {7 var password = 'myCurrentPassword';8 auth.changeEmail({9 password: password,10 newEmail: 'auth_test@newemail.com'11 });12 auth.changePassword({13 currentPassword: password,14 newPassword: 'myNewPa55Word'15 });16 }17 changeEmailAndPassword();18});Important Notes
- Ensure you replace the placeholder values for both the current and new password/email addresses with accurate information from your NetSuite account to avoid errors.
- This script can be executed in the SuiteScript Debugger, but it needs to be adapted for deployment scripts to function correctly.
Error Handling for N/auth Methods
When using the methods auth.changeEmail and auth.changePassword, it’s important to handle potential errors:
| Error Code | Thrown If |
|---|---|
INVALID_EMAIL | The options.newEmail provided is invalid. |
INVALID_PSWD | The options.password does not meet the required rules. |
SSS_MISSING_REQD_PARAMETER | Required parameters options.newEmail or options.password are missing. |
WRONG_PARAMETER_TYPE | The options.onlyThisAccount is not specified as a boolean. |
Common Parameters
The methods utilize the following parameters:
options.newEmail: (string, required) The new email address for the user.options.password: (string, required) The current password for authentication.options.onlyThisAccount: (boolean, optional) Limits the email change to roles within the current account if set to true.
Who This Affects
The N/auth module is particularly relevant for:
- Administrators: Who need to manage user accounts.
- Developers: Implementing credential management solutions in custom scripts.
Key Takeaways
- The N/auth module streamlines user credential management in NetSuite.
- Proper error handling is essential when changing user credentials.
- Placeholder values in scripts must be replaced with real account values.
Source: This article is based on Oracle's official NetSuite documentation.
Frequently Asked Questions (4)
What script types support the N/auth module methods?
Are there any required parameters when using the auth.changeEmail method?
Can I specify a role limitation when changing a user's email in NetSuite?
What error might be encountered if a new email address is not properly formatted?
Was this article helpful?
More in Authentication
- SuiteCommerce Authentication Enhancements in NetSuite 2024.1
SuiteCommerce authentication enhancements introduced in version 2024.1 improve security and personalization in eCommerce solutions.
- Domain Settings Transition to DNS Challenges in NetSuite 2024.1
Starting in NetSuite 2024.1, domain verification shifts from HTTP to DNS challenges, enhancing security and streamlining configurations.
- End of Support for RSA PKCSv1.5 in NetSuite 2025.1
NetSuite 2025.1 ends support for RSA PKCSv1.5 in OAuth 2.0, requiring updates to integration methods.
- End of Support for SMS/Voice Call 2FA in NetSuite 2023.2
NetSuite 2024.1 discontinues SMS/voice call 2FA. Transition to an authenticator app is required by March 1, 2024.
Advertising
Reach Authentication Professionals
Put your product in front of NetSuite experts who work with Authentication every day.
Sponsor This Category