Correct log out from all DCs
This commit is contained in:
parent
fe711d9432
commit
f607fdf72e
@ -31,18 +31,27 @@ angular.module('izhukov.mtproto.wrapper', ['izhukov.utils', 'izhukov.mtproto'])
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mtpLogOut () {
|
function mtpLogOut () {
|
||||||
return mtpInvokeApi('auth.logOut').then(function () {
|
var storageKeys = [];
|
||||||
|
for (var dcID = 1; dcID <= 5; dcID++) {
|
||||||
|
storageKeys.push('dc' + dcID + '_auth_key');
|
||||||
|
}
|
||||||
|
return Storage.get.apply(Storage, storageKeys).then(function (storageResult) {
|
||||||
|
var logoutPromises = [];
|
||||||
|
for (var i = 0; i < storageResult.length; i++) {
|
||||||
|
if (storageResult[i]) {
|
||||||
|
logoutPromises.push(mtpInvokeApi('auth.logOut', {}, {dcID: i + 1}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $q.all(logoutPromises).then(function () {
|
||||||
Storage.remove('dc', 'user_auth');
|
Storage.remove('dc', 'user_auth');
|
||||||
|
|
||||||
baseDcID = false;
|
baseDcID = false;
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
|
Storage.remove.apply(storageKeys);
|
||||||
Storage.remove('dc', 'user_auth');
|
Storage.remove('dc', 'user_auth');
|
||||||
if (error && error.code != 401) {
|
|
||||||
Storage.remove('dc' + baseDcID + '_auth_key');
|
|
||||||
}
|
|
||||||
baseDcID = false;
|
baseDcID = false;
|
||||||
error.handled = true;
|
error.handled = true;
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function mtpGetNetworker (dcID, options) {
|
function mtpGetNetworker (dcID, options) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user