Skip to content
Snippets Groups Projects
Commit 52b64bcf authored by Brad Kittenbrink's avatar Brad Kittenbrink
Browse files

Fix SL-18511 TOS and MFA login failure handlers must cooperate to answer both...

Fix SL-18511 TOS and MFA login failure handlers must cooperate to answer both reasons at the same time
parent a022452f
No related branches found
No related tags found
No related merge requests found
...@@ -451,26 +451,8 @@ void LLLoginInstance::handleLoginFailure(const LLSD& event) ...@@ -451,26 +451,8 @@ void LLLoginInstance::handleLoginFailure(const LLSD& event)
LLSD args(llsd::map( "MESSAGE", LLTrans::getString(response["message_id"]) )); LLSD args(llsd::map( "MESSAGE", LLTrans::getString(response["message_id"]) ));
LLSD payload; LLSD payload;
LLNotificationsUtil::add("PromptMFAToken", args, payload, [=](LLSD const & notif, LLSD const & response) { LLNotificationsUtil::add("PromptMFAToken", args, payload,
bool continue_clicked = response["continue"].asBoolean(); boost::bind(&LLLoginInstance::handleMFAChallenge, this, _1, _2));
std::string token = response["token"].asString();
LL_DEBUGS("LLLogin") << "PromptMFAToken: response: " << response << " continue_clicked" << continue_clicked << LL_ENDL;
// strip out whitespace - SL-17034/BUG-231938
token = boost::regex_replace(token, boost::regex("\\s"), "");
if (continue_clicked && !token.empty())
{
LL_INFOS("LLLogin") << "PromptMFAToken: token submitted" << LL_ENDL;
// Set the request data to true and retry login.
mRequestData["params"]["token"] = token;
reconnect();
} else {
LL_INFOS("LLLogin") << "PromptMFAToken: no token, attemptComplete" << LL_ENDL;
attemptComplete();
}
});
} }
else if( reason_response == "key" else if( reason_response == "key"
|| reason_response == "presence" || reason_response == "presence"
...@@ -547,23 +529,59 @@ void LLLoginInstance::handleIndeterminate(const LLSD& event) ...@@ -547,23 +529,59 @@ void LLLoginInstance::handleIndeterminate(const LLSD& event)
bool LLLoginInstance::handleTOSResponse(bool accepted, const std::string& key) bool LLLoginInstance::handleTOSResponse(bool accepted, const std::string& key)
{ {
if(accepted) if(accepted)
{ {
LL_INFOS("LLLogin") << "LLLoginInstance::handleTOSResponse: accepted" << LL_ENDL; LL_INFOS("LLLogin") << "LLLoginInstance::handleTOSResponse: accepted " << LL_ENDL;
// Set the request data to true and retry login. // Set the request data to true and retry login.
mRequestData["params"][key] = true; mRequestData["params"][key] = true;
reconnect();
}
else
{
LL_INFOS("LLLogin") << "LLLoginInstance::handleTOSResponse: attemptComplete" << LL_ENDL;
attemptComplete(); if (!mRequestData["params"]["token"].asString().empty())
} {
// SL-18511 this TOS failure happened while we are in the middle of an MFA challenge/response.
// the previously entered token is very likely expired, so prompt again
LLSD args(llsd::map( "MESSAGE", LLTrans::getString("LoginFailedAuthenticationMFARequired") ));
LLSD payload;
LLNotificationsUtil::add("PromptMFAToken", args, payload,
boost::bind(&LLLoginInstance::handleMFAChallenge, this, _1, _2));
}
else
{
reconnect();
}
}
else
{
LL_INFOS("LLLogin") << "LLLoginInstance::handleTOSResponse: attemptComplete" << LL_ENDL;
attemptComplete();
}
LLEventPumps::instance().obtain(TOS_REPLY_PUMP).stopListening(TOS_LISTENER_NAME);
return true;
}
LLEventPumps::instance().obtain(TOS_REPLY_PUMP).stopListening(TOS_LISTENER_NAME); bool LLLoginInstance::handleMFAChallenge(LLSD const & notif, LLSD const & response)
return true; {
bool continue_clicked = response["continue"].asBoolean();
std::string token = response["token"].asString();
LL_DEBUGS("LLLogin") << "PromptMFAToken: response: " << response << " continue_clicked" << continue_clicked << LL_ENDL;
// strip out whitespace - SL-17034/BUG-231938
token = boost::regex_replace(token, boost::regex("\\s"), "");
if (continue_clicked && !token.empty())
{
LL_INFOS("LLLogin") << "PromptMFAToken: token submitted" << LL_ENDL;
// Set the request data to true and retry login.
mRequestData["params"]["token"] = token;
reconnect();
} else {
LL_INFOS("LLLogin") << "PromptMFAToken: no token, attemptComplete" << LL_ENDL;
attemptComplete();
}
return true;
} }
std::string construct_start_string() std::string construct_start_string()
......
...@@ -84,6 +84,7 @@ class LLLoginInstance : public LLSingleton<LLLoginInstance> ...@@ -84,6 +84,7 @@ class LLLoginInstance : public LLSingleton<LLLoginInstance>
void syncWithUpdater(ResponsePtr resp, const LLSD& notification, const LLSD& response); void syncWithUpdater(ResponsePtr resp, const LLSD& notification, const LLSD& response);
bool handleTOSResponse(bool v, const std::string& key); bool handleTOSResponse(bool v, const std::string& key);
bool handleMFAChallenge(LLSD const & notif, LLSD const & response);
void attemptComplete() { mAttemptComplete = true; } // In the future an event? void attemptComplete() { mAttemptComplete = true; } // In the future an event?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment