Create a session for a user by entering a username and password. If the user
requires a password reset, the "resetPasswordCallback" property will be
returned. This function should be called with the new password once entered
by the user. If the user requires an MFA token, the "mfaCodeCallback"
property will be returned. This function should be called with a one-time
token generated from an authenticator app. The functions returned are
recursive and the result from each of them is the same result from the
loginUsernamePassword() function. Each time the response includes a callback,
you will need to begin the process again until all callbacks are handled.
Example
asyncfunctionhandleLoginAttemptResponse({ resetPasswordCallback, mfaCodeCallback, }) { // "resetPasswordCallback" will be undefined if a password reset was not required. if (resetPasswordCallback) { // Prompt the user to enter a new password constnewPassword = prompt( 'The password you entered was only temporary, and must be reset for security purposes. Please enter your new password below to continue.', ) constresetPasswordResponse = awaitresetPasswordCallback(newPassword) returnawaithandleLoginAttemptResponse(resetPasswordResponse) }
// "mfaCodeCallback" will be undefined if MFA is not setup. if (mfaCodeCallback) { // Prompt the user to enter an MFA code constcode = prompt( 'Please enter a one-time code from your MFA app.', ) constmfaCodeResponse = awaitmfaCodeCallback(code) returnawaithandleLoginAttemptResponse(mfaCodeResponse) } }
Create a session for a user by entering a username and password. If the user requires a password reset, the "resetPasswordCallback" property will be returned. This function should be called with the new password once entered by the user. If the user requires an MFA token, the "mfaCodeCallback" property will be returned. This function should be called with a one-time token generated from an authenticator app. The functions returned are recursive and the result from each of them is the same result from the loginUsernamePassword() function. Each time the response includes a callback, you will need to begin the process again until all callbacks are handled.
Example