diff --git a/Telegram/SourceFiles/auth_session.cpp b/Telegram/SourceFiles/auth_session.cpp index 0e51c57191..3e055a7c31 100644 --- a/Telegram/SourceFiles/auth_session.cpp +++ b/Telegram/SourceFiles/auth_session.cpp @@ -304,7 +304,10 @@ base::Observable &AuthSession::downloaderTaskFinished() { } 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.")); App::logOutDelayed(); return false; @@ -314,6 +317,7 @@ bool AuthSession::validateSelf(const MTPUser &user) { void AuthSession::saveSettingsDelayed(TimeMs delay) { Expects(this == &Auth()); + _saveDataTimer.callOnce(delay); } diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 6ed71e8d93..be979d2251 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -3717,8 +3717,11 @@ void MainWidget::start(const MTPUser *self) { if (!self) { MTP::send(MTPusers_GetFullUser(MTP_inputUserSelf()), rpcDone(&MainWidget::startWithSelf)); return; - } - if (!Auth().validateSelf(*self)) { + } else if (!Auth().validateSelf(*self)) { + constexpr auto kRequestUserAgainTimeout = TimeMs(10000); + App::CallDelayed(kRequestUserAgainTimeout, this, [=] { + MTP::send(MTPusers_GetFullUser(MTP_inputUserSelf()), rpcDone(&MainWidget::startWithSelf)); + }); return; } diff --git a/Telegram/SourceFiles/mtproto/mtp_instance.cpp b/Telegram/SourceFiles/mtproto/mtp_instance.cpp index d366c66ccf..9e173fa762 100644 --- a/Telegram/SourceFiles/mtproto/mtp_instance.cpp +++ b/Telegram/SourceFiles/mtproto/mtp_instance.cpp @@ -942,10 +942,13 @@ void Instance::Private::importDone(const MTPauth_Authorization &result, mtpReque const auto shiftedDcId = queryRequestByDc(requestId); if (!shiftedDcId) { 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()) { - (*_globalHandler.onFail)(requestId, error); // auth failed in main dc - } + // + // Don't log out on export/import problems, perhaps this is a server side error. + // + //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; } 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) { 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; } @@ -990,10 +996,13 @@ void Instance::Private::exportDone(const MTPauth_ExportedAuthorization &result, auto it = _authExportRequests.find(requestId); if (it == _authExportRequests.cend()) { 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()) { - (*_globalHandler.onFail)(requestId, error); // auth failed in main dc - } + // + // Don't log out on export/import problems, perhaps this is a server side error. + // + //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; } @@ -1013,9 +1022,12 @@ bool Instance::Private::exportFail(const RPCError &error, mtpRequestId requestId if (it != _authExportRequests.cend()) { _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; }