AddQuestion()

// in class: Session
function AddQuestion(pos: number, q, a: string, echo: boolean): void;

This function adds a custom question with a precise pre-defined answer to the list of questions that will be asked during keyboard-interactive authentication.

Warning

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

The parameters are as follows:

Parameter Type Explanation
pos number The question’s zero-based position; when, in the sequence, this question should be asked
q string The question (should end with a colon :)
a string The pre-defined expected (correct) answer
echo boolean Whether or not the answer should be echoed back to the client (hint: passwords/secrets should not)

Example

{
  // 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);
}