mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-24 20:33:19 +00:00
Don't logout on some server-side problems.
This commit is contained in:
parent
7d8ba15252
commit
8764da787b
Telegram/SourceFiles
@ -304,7 +304,10 @@ base::Observable<void> &AuthSession::downloaderTaskFinished() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool AuthSession::validateSelf(const MTPUser &user) {
|
bool AuthSession::validateSelf(const MTPUser &user) {
|
||||||
if (user.type() != mtpc_user || !user.c_user().is_self() || user.c_user().vid.v != userId()) {
|
if (user.type() != mtpc_user || !user.c_user().is_self()) {
|
||||||
|
LOG(("API Error: bad self user received."));
|
||||||
|
return false;
|
||||||
|
} else if (user.c_user().vid.v != userId()) {
|
||||||
LOG(("Auth Error: wrong self user received."));
|
LOG(("Auth Error: wrong self user received."));
|
||||||
App::logOutDelayed();
|
App::logOutDelayed();
|
||||||
return false;
|
return false;
|
||||||
@ -314,6 +317,7 @@ bool AuthSession::validateSelf(const MTPUser &user) {
|
|||||||
|
|
||||||
void AuthSession::saveSettingsDelayed(TimeMs delay) {
|
void AuthSession::saveSettingsDelayed(TimeMs delay) {
|
||||||
Expects(this == &Auth());
|
Expects(this == &Auth());
|
||||||
|
|
||||||
_saveDataTimer.callOnce(delay);
|
_saveDataTimer.callOnce(delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3717,8 +3717,11 @@ void MainWidget::start(const MTPUser *self) {
|
|||||||
if (!self) {
|
if (!self) {
|
||||||
MTP::send(MTPusers_GetFullUser(MTP_inputUserSelf()), rpcDone(&MainWidget::startWithSelf));
|
MTP::send(MTPusers_GetFullUser(MTP_inputUserSelf()), rpcDone(&MainWidget::startWithSelf));
|
||||||
return;
|
return;
|
||||||
}
|
} else if (!Auth().validateSelf(*self)) {
|
||||||
if (!Auth().validateSelf(*self)) {
|
constexpr auto kRequestUserAgainTimeout = TimeMs(10000);
|
||||||
|
App::CallDelayed(kRequestUserAgainTimeout, this, [=] {
|
||||||
|
MTP::send(MTPusers_GetFullUser(MTP_inputUserSelf()), rpcDone(&MainWidget::startWithSelf));
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -942,10 +942,13 @@ void Instance::Private::importDone(const MTPauth_Authorization &result, mtpReque
|
|||||||
const auto shiftedDcId = queryRequestByDc(requestId);
|
const auto shiftedDcId = queryRequestByDc(requestId);
|
||||||
if (!shiftedDcId) {
|
if (!shiftedDcId) {
|
||||||
LOG(("MTP Error: auth import request not found in requestsByDC, requestId: %1").arg(requestId));
|
LOG(("MTP Error: auth import request not found in requestsByDC, requestId: %1").arg(requestId));
|
||||||
RPCError error(internal::rpcClientError("AUTH_IMPORT_FAIL", QString("did not find import request in requestsByDC, request %1").arg(requestId)));
|
//
|
||||||
if (_globalHandler.onFail && hasAuthorization()) {
|
// Don't log out on export/import problems, perhaps this is a server side error.
|
||||||
(*_globalHandler.onFail)(requestId, error); // auth failed in main dc
|
//
|
||||||
}
|
//RPCError error(internal::rpcClientError("AUTH_IMPORT_FAIL", QString("did not find import request in requestsByDC, request %1").arg(requestId)));
|
||||||
|
//if (_globalHandler.onFail && hasAuthorization()) {
|
||||||
|
// (*_globalHandler.onFail)(requestId, error); // auth failed in main dc
|
||||||
|
//}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto newdc = bareDcId(*shiftedDcId);
|
auto newdc = bareDcId(*shiftedDcId);
|
||||||
@ -980,9 +983,12 @@ void Instance::Private::importDone(const MTPauth_Authorization &result, mtpReque
|
|||||||
bool Instance::Private::importFail(const RPCError &error, mtpRequestId requestId) {
|
bool Instance::Private::importFail(const RPCError &error, mtpRequestId requestId) {
|
||||||
if (isDefaultHandledError(error)) return false;
|
if (isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
if (_globalHandler.onFail && hasAuthorization()) {
|
//
|
||||||
(*_globalHandler.onFail)(requestId, error); // auth import failed
|
// Don't log out on export/import problems, perhaps this is a server side error.
|
||||||
}
|
//
|
||||||
|
//if (_globalHandler.onFail && hasAuthorization()) {
|
||||||
|
// (*_globalHandler.onFail)(requestId, error); // auth import failed
|
||||||
|
//}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -990,10 +996,13 @@ void Instance::Private::exportDone(const MTPauth_ExportedAuthorization &result,
|
|||||||
auto it = _authExportRequests.find(requestId);
|
auto it = _authExportRequests.find(requestId);
|
||||||
if (it == _authExportRequests.cend()) {
|
if (it == _authExportRequests.cend()) {
|
||||||
LOG(("MTP Error: auth export request target dcWithShift not found, requestId: %1").arg(requestId));
|
LOG(("MTP Error: auth export request target dcWithShift not found, requestId: %1").arg(requestId));
|
||||||
RPCError error(internal::rpcClientError("AUTH_IMPORT_FAIL", QString("did not find target dcWithShift, request %1").arg(requestId)));
|
//
|
||||||
if (_globalHandler.onFail && hasAuthorization()) {
|
// Don't log out on export/import problems, perhaps this is a server side error.
|
||||||
(*_globalHandler.onFail)(requestId, error); // auth failed in main dc
|
//
|
||||||
}
|
//RPCError error(internal::rpcClientError("AUTH_IMPORT_FAIL", QString("did not find target dcWithShift, request %1").arg(requestId)));
|
||||||
|
//if (_globalHandler.onFail && hasAuthorization()) {
|
||||||
|
// (*_globalHandler.onFail)(requestId, error); // auth failed in main dc
|
||||||
|
//}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1013,9 +1022,12 @@ bool Instance::Private::exportFail(const RPCError &error, mtpRequestId requestId
|
|||||||
if (it != _authExportRequests.cend()) {
|
if (it != _authExportRequests.cend()) {
|
||||||
_authWaiters[bareDcId(it->second)].clear();
|
_authWaiters[bareDcId(it->second)].clear();
|
||||||
}
|
}
|
||||||
if (_globalHandler.onFail && hasAuthorization()) {
|
//
|
||||||
(*_globalHandler.onFail)(requestId, error); // auth failed in main dc
|
// Don't log out on export/import problems, perhaps this is a server side error.
|
||||||
}
|
//
|
||||||
|
//if (_globalHandler.onFail && hasAuthorization()) {
|
||||||
|
// (*_globalHandler.onFail)(requestId, error); // auth failed in main dc
|
||||||
|
//}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user