Skip to content

AddQuestionTOTP()

ts
// in class: Session
function AddQuestionTOTP(pos: number, q: string): void;

This function adds a question to the list of questions that will be asked during keyboard-interactive authentication, specifically to ask for the user TOTP (time-based one time password) generated by Google Authenticator. To be able to provide this TOTP, clearly, the user must already be enrolled in 2FA/MFA via WebClient!

CAUTION

For obvious reasons this function should always only be used inside of an OnAuthInteractiveSetQuestions event-handler.

The parameters are as follows:

ParameterTypeExplanation
posnumberThe question's zero-based position; when, in the sequence, this question should be asked
qstringThe question (should end with a colon :)

Example

ts
{
  // First, ask for the user's password
  Session.AddQuestionPassword(0, 'Type your password:');
  // Next, ask for Google Authenticator OTP (for 2FA/MFA)
  Session.AddQuestionTOTP(1, 'Type your Authenticator OTP:');
  // Then ask for any question we want
  Session.AddQuestion(2, 'Life, the Universe and Everything:', 42, true);
}