| 51 | } |
| 52 | |
| 53 | void XboxAuthorizationStep::onRequestDone( |
| 54 | QNetworkReply::NetworkError error, |
| 55 | QByteArray data, |
| 56 | QList<QNetworkReply::RawHeaderPair> headers |
| 57 | ) { |
| 58 | auto requestor = qobject_cast<AuthRequest *>(QObject::sender()); |
| 59 | requestor->deleteLater(); |
| 60 | |
| 61 | #ifndef NDEBUG |
| 62 | qDebug() << data; |
| 63 | #endif |
| 64 | if (error != QNetworkReply::NoError) { |
| 65 | qWarning() << "Reply error:" << error; |
| 66 | if (Net::isApplicationError(error)) { |
| 67 | if(!processSTSError(error, data, headers)) { |
| 68 | emit finished( |
| 69 | AccountTaskState::STATE_FAILED_SOFT, |
| 70 | tr("Failed to get authorization for %1 services. Error %2.").arg(m_authorizationKind, error) |
| 71 | ); |
| 72 | } |
| 73 | else { |
| 74 | emit finished( |
| 75 | AccountTaskState::STATE_FAILED_SOFT, |
| 76 | tr("Unknown STS error for %1 services: %2").arg(m_authorizationKind, requestor->errorString_) |
| 77 | ); |
| 78 | } |
| 79 | } |
| 80 | else { |
| 81 | emit finished( |
| 82 | AccountTaskState::STATE_OFFLINE, |
| 83 | tr("Failed to get authorization for %1 services: %2").arg(m_authorizationKind, requestor->errorString_) |
| 84 | ); |
| 85 | } |
| 86 | return; |
| 87 | } |
| 88 | |
| 89 | Katabasis::Token temp; |
| 90 | if(!Parsers::parseXTokenResponse(data, temp, m_authorizationKind)) { |
| 91 | emit finished( |
| 92 | AccountTaskState::STATE_FAILED_SOFT, |
| 93 | tr("Could not parse authorization response for access to %1 services.").arg(m_authorizationKind) |
| 94 | ); |
| 95 | return; |
| 96 | } |
| 97 | |
| 98 | if(temp.extra["uhs"] != m_data->userToken.extra["uhs"]) { |
| 99 | emit finished( |
| 100 | AccountTaskState::STATE_FAILED_SOFT, |
| 101 | tr("Server has changed %1 authorization user hash in the reply. Something is wrong.").arg(m_authorizationKind) |
| 102 | ); |
| 103 | return; |
| 104 | } |
| 105 | auto & token = *m_token; |
| 106 | token = temp; |
| 107 | |
| 108 | emit finished(AccountTaskState::STATE_WORKING, tr("Got authorization to access %1").arg(m_relyingParty)); |
| 109 | } |
| 110 |
nothing calls this directly
no test coverage detected