Skip to content

Commit

Permalink
smapi auth: check for key or token not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
janbar committed Jul 26, 2019
1 parent abb3aef commit d0fc1f2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions noson/src/smapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ bool SMAPI::GetDeviceAuthToken(SMOAKeyring::Data& auth)
}
oa.key = vars.GetValue("privateKey");
oa.token = vars.GetValue("authToken");
if (!oa.key.empty())
if (!oa.key.empty() || !oa.token.empty())
{
// set credentials for the account and reset the auth expiration
m_service->GetAccount()->SetCredentials(oa);
Expand Down Expand Up @@ -557,7 +557,8 @@ bool SMAPI::makeSoapHeader()
SMAccount::Credentials auth = m_service->GetAccount()->GetCredentials();
m_soapHeader.append("<loginToken>");
m_soapHeader.append("<token>").append(auth.token.empty() ? auth.devId : auth.token).append("</token>");
m_soapHeader.append("<key>").append(auth.key).append("</key>");
if (!auth.key.empty())
m_soapHeader.append("<key>").append(auth.key).append("</key>");
m_soapHeader.append("<householdId>").append(m_deviceHouseholdID).append("</householdId>");
m_soapHeader.append("</loginToken>");
}
Expand Down

0 comments on commit d0fc1f2

Please sign in to comment.