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.
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
- OpenID Connect (OIDC) Configuration in NetSuite
OpenID Connect (OIDC) enables secure access to NetSuite web stores, improving user security management.
- Single Sign-On Only Role Configuration in NetSuite
Configure Single Sign-On Only roles in NetSuite to ensure users can access accounts solely through OIDC SSO.
- Token-Based Authentication Deprecation in NetSuite 2026.2
NetSuite 2026.2 announces the deprecation of Token-Based Authentication for new integrations, urging migration to OAuth 2.0.
- Outbound Single Sign-on Deprecation and Alternatives in NetSuite
Outbound Single Sign-on (SuiteSignOn) is deprecated in NetSuite 2024.1, affecting authentication processes.
Advertising
Reach Authentication Professionals
Put your product in front of NetSuite experts who work with Authentication every day.
Sponsor This Category