From 30cd108c7e4a524c9f17060d5b2f7b4ff193b4b8 Mon Sep 17 00:00:00 2001
From: Brad Kittenbrink <brad@lindenlab.com>
Date: Mon, 6 Dec 2021 16:17:55 -0800
Subject: [PATCH] SL-16388 Viewer MFA Implementation Improvements

token input is now handled and message formatting is improved.
Added beginnings of support for saving slmfa_hash value client side.
---
 indra/newview/llfloatermfa.cpp                | 27 ++++++++++---------
 indra/newview/lllogininstance.cpp             |  1 +
 .../skins/default/xui/en/floater_mfa.xml      | 25 ++++++++---------
 3 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/indra/newview/llfloatermfa.cpp b/indra/newview/llfloatermfa.cpp
index 9fb6788923f..9356605b8c0 100644
--- a/indra/newview/llfloatermfa.cpp
+++ b/indra/newview/llfloatermfa.cpp
@@ -46,35 +46,36 @@ LLFloaterMFA::~LLFloaterMFA()
 
 BOOL LLFloaterMFA::postBuild()
 {
-    childSetAction("Continue", onContinue, this);
-    childSetAction("Cancel", onCancel, this);
+    centerOnScreen();
 
-    if (hasChild("token_prompt"))
+    childSetAction("continue_btn", onContinue, this);
+    childSetAction("cancel_btn", onCancel, this);
+    childSetCommitCallback("token_edit", [](LLUICtrl*, void* userdata) { onContinue(userdata);}, this);
+
+    if (hasChild("token_prompt_text"))
     {
         // this displays the prompt message
-        LLUICtrl *token_prompt = getChild<LLUICtrl>("token_prompt");
+        LLUICtrl *token_prompt = getChild<LLUICtrl>("token_prompt_text");
         token_prompt->setEnabled( FALSE );
         token_prompt->setFocus(TRUE);
         token_prompt->setValue(LLSD(mMessage));
-
-        return TRUE;
     }
 
     return TRUE;
 }
 
 // static
-void LLFloaterMFA::onContinue( void* userdata )
+void LLFloaterMFA::onContinue(void* userdata )
 {
-    LLFloaterMFA* self = (LLFloaterMFA*) userdata;
+    LLFloaterMFA* self = static_cast<LLFloaterMFA*>(userdata);
     LL_INFOS("MFA") << "User submits MFA token for challenge." << LL_ENDL;
 
-    std::string token{"8675309"};
+    std::string token;
 
-    if (self->hasChild("token"))
+    if (self->hasChild("token_edit"))
     {
         // this displays the prompt message
-        LLUICtrl *token_ctrl = self->getChild<LLUICtrl>("token");
+        LLUICtrl *token_ctrl = self->getChild<LLUICtrl>("token_edit");
 
         token = token_ctrl->getValue().asStringRef();
     }
@@ -88,9 +89,9 @@ void LLFloaterMFA::onContinue( void* userdata )
 }
 
 // static
-void LLFloaterMFA::onCancel( void* userdata )
+void LLFloaterMFA::onCancel(void* userdata)
 {
-    LLFloaterMFA* self = (LLFloaterMFA*) userdata;
+    LLFloaterMFA* self = static_cast<LLFloaterMFA*>(userdata);
     LL_INFOS("MFA") << "User cancels MFA challenge attempt." << LL_ENDL;
 
     if(self->mReplyPumpName != "")
diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp
index e380e5a3f42..553a8c91ffc 100644
--- a/indra/newview/lllogininstance.cpp
+++ b/indra/newview/lllogininstance.cpp
@@ -228,6 +228,7 @@ void LLLoginInstance::constructAuthParams(LLPointer<LLCredential> user_credentia
 	request_params["host_id"] = gSavedSettings.getString("HostID");
 	request_params["extended_errors"] = true; // request message_id and message_args
 	request_params["token"] = "";
+	request_params["slmfa_hash"] = "";
 
     // log request_params _before_ adding the credentials   
     LL_DEBUGS("LLLogin") << "Login parameters: " << LLSDOStreamer<LLSDNotationFormatter>(request_params) << LL_ENDL;
diff --git a/indra/newview/skins/default/xui/en/floater_mfa.xml b/indra/newview/skins/default/xui/en/floater_mfa.xml
index acdfbc82c0b..361641d313d 100644
--- a/indra/newview/skins/default/xui/en/floater_mfa.xml
+++ b/indra/newview/skins/default/xui/en/floater_mfa.xml
@@ -1,42 +1,43 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <floater
+ title="MFA Token Requred"
  legacy_header_height="18"
  can_minimize="false"
- height="87"
+ can_close="false"
+ height="110"
  layout="topleft"
  name="mfa_challenge"
  help_topic="mfa_challenge"
  width="480">
     <text
      type="string"
+     word_wrap="true"
      length="1"
-     bottom="20"
      follows="top|left"
      height="15"
      layout="topleft"
      left="10"
-     name="token_prompt"
+     name="token_prompt_text"
      top="20">
         token prompt
     </text>
-    <text_box
+    <line_editor
      allow_text_entry="true"
      follows="left|top|right"
      height="19"
      layout="topleft"
-     left_delta="70"
+     bottom_delta="40"
      max_chars="16"
-     name="token_entry"
-     top_delta="-4"
-     width="16" />
+     name="token_edit"
+     width="100" />
     <button
      follows="top|left"
      height="20"
      label="Continue"
      layout="topleft"
      left="10"
-     name="Continue"
-     top="50"
+     name="continue_btn"
+     bottom_delta="30"
      width="64" />
     <button
      follows="top|left"
@@ -44,7 +45,7 @@
      label="Cancel"
      layout="topleft"
      left_pad="5"
-     name="Cancel"
-     top_delta="0"
+     name="cancel_btn"
+     bottom_delta="0"
      width="64" />
 </floater>
-- 
GitLab