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.

·2 min read·View Oracle Docs

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 TypeNameReturn TypeSupported Script TypesDescription
Methodauth.changeEmail(options)voidServer scriptsChanges the current user's email address.
Methodauth.changePassword(options)voidServer scriptsChanges 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:

suitescript
1/**
2 * @NApiVersion 2.x
3 */
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 CodeThrown If
INVALID_EMAILThe options.newEmail provided is invalid.
INVALID_PSWDThe options.password does not meet the required rules.
SSS_MISSING_REQD_PARAMETERRequired parameters options.newEmail or options.password are missing.
WRONG_PARAMETER_TYPEThe 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?
The N/auth module methods are supported in server scripts.
Are there any required parameters when using the auth.changeEmail method?
Yes, the auth.changeEmail method requires the parameters options.newEmail and options.password.
Can I specify a role limitation when changing a user's email in NetSuite?
Yes, by setting the options.onlyThisAccount parameter to true, you can limit the email change to roles within the current account.
What error might be encountered if a new email address is not properly formatted?
If the new email address is not properly formatted, the error code INVALID_EMAIL will be thrown.
Source: N/auth Module Members Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Authentication

View all Authentication articles →