Fixed baseDcId update for authorization
This commit is contained in:
parent
0cbaae7806
commit
9ca91d02c5
@ -33,12 +33,12 @@
|
|||||||
|
|
||||||
|
|
||||||
<script type="text/javascript" src="js/lib/config.js"></script>
|
<script type="text/javascript" src="js/lib/config.js"></script>
|
||||||
<script type="text/javascript" src="js/lib/mtproto.js?5"></script>
|
<script type="text/javascript" src="js/lib/mtproto.js?6"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="js/util.js"></script>
|
<script type="text/javascript" src="js/util.js"></script>
|
||||||
<script type="text/javascript" src="js/app.js?3"></script>
|
<script type="text/javascript" src="js/app.js?3"></script>
|
||||||
<script type="text/javascript" src="js/services.js?6"></script>
|
<script type="text/javascript" src="js/services.js?6"></script>
|
||||||
<script type="text/javascript" src="js/controllers.js?7"></script>
|
<script type="text/javascript" src="js/controllers.js?8"></script>
|
||||||
<script type="text/javascript" src="js/filters.js?3"></script>
|
<script type="text/javascript" src="js/filters.js?3"></script>
|
||||||
<script type="text/javascript" src="js/directives.js?5"></script>
|
<script type="text/javascript" src="js/directives.js?5"></script>
|
||||||
|
|
||||||
|
@ -22,13 +22,13 @@ angular.module('myApp.controllers', [])
|
|||||||
})
|
})
|
||||||
|
|
||||||
.controller('AppLoginController', function ($scope, $location, MtpApiManager, ErrorService) {
|
.controller('AppLoginController', function ($scope, $location, MtpApiManager, ErrorService) {
|
||||||
var dcID = 1;
|
var options = {dcID: 1};
|
||||||
|
|
||||||
$scope.credentials = {};
|
$scope.credentials = {};
|
||||||
$scope.progress = {};
|
$scope.progress = {};
|
||||||
|
|
||||||
function saveAuth (result) {
|
function saveAuth (result) {
|
||||||
MtpApiManager.setUserAuth(dcID, {
|
MtpApiManager.setUserAuth(options.dcID, {
|
||||||
expires: result.expires,
|
expires: result.expires,
|
||||||
id: result.user.id
|
id: result.user.id
|
||||||
});
|
});
|
||||||
@ -40,7 +40,7 @@ angular.module('myApp.controllers', [])
|
|||||||
$scope.progress.enabled = true;
|
$scope.progress.enabled = true;
|
||||||
MtpApiManager.invokeApi('auth.checkPhone', {
|
MtpApiManager.invokeApi('auth.checkPhone', {
|
||||||
phone_number: $scope.credentials.phone_number
|
phone_number: $scope.credentials.phone_number
|
||||||
}, {dcID: dcID}).then(function (result) {
|
}, options).then(function (result) {
|
||||||
$scope.progress.enabled = false;
|
$scope.progress.enabled = false;
|
||||||
if (!result.phone_registered) {
|
if (!result.phone_registered) {
|
||||||
ErrorService.showSimpleError('No account', 'Sorry, there is no Telegram account for ' + $scope.credentials.phone_number + '. Please sign up using our mobile apps.');
|
ErrorService.showSimpleError('No account', 'Sorry, there is no Telegram account for ' + $scope.credentials.phone_number + '. Please sign up using our mobile apps.');
|
||||||
@ -53,7 +53,7 @@ angular.module('myApp.controllers', [])
|
|||||||
sms_type: 0,
|
sms_type: 0,
|
||||||
api_id: 2496,
|
api_id: 2496,
|
||||||
api_hash: '8da85b0d5bfe62527e5b244c209159c3'
|
api_hash: '8da85b0d5bfe62527e5b244c209159c3'
|
||||||
}, {dcID: dcID}).then(function (sentCode) {
|
}, options).then(function (sentCode) {
|
||||||
$scope.progress.enabled = false;
|
$scope.progress.enabled = false;
|
||||||
|
|
||||||
$scope.credentials.phone_code_hash = sentCode.phone_code_hash;
|
$scope.credentials.phone_code_hash = sentCode.phone_code_hash;
|
||||||
@ -98,7 +98,7 @@ angular.module('myApp.controllers', [])
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scope.progress.enabled = true;
|
$scope.progress.enabled = true;
|
||||||
MtpApiManager.invokeApi(method, params, {dcID: dcID}).then(saveAuth, function (error) {
|
MtpApiManager.invokeApi(method, params, options).then(saveAuth, function (error) {
|
||||||
$scope.progress.enabled = false;
|
$scope.progress.enabled = false;
|
||||||
if (error.code == 400 && error.type == 'PHONE_NUMBER_UNOCCUPIED') {
|
if (error.code == 400 && error.type == 'PHONE_NUMBER_UNOCCUPIED') {
|
||||||
return $scope.logIn(true);
|
return $scope.logIn(true);
|
||||||
|
@ -2244,7 +2244,11 @@ factory('MtpApiManager', function (AppConfigManager, MtpAuthorizer, MtpNetworker
|
|||||||
else if (error.code == 303) {
|
else if (error.code == 303) {
|
||||||
var newDcID = error.type.match(/^(PHONE_MIGRATE_|NETWORK_MIGRATE_)(\d+)/)[2];
|
var newDcID = error.type.match(/^(PHONE_MIGRATE_|NETWORK_MIGRATE_)(\d+)/)[2];
|
||||||
if (newDcID != dcID) {
|
if (newDcID != dcID) {
|
||||||
AppConfigManager.set({dc: baseDcID = dcID});
|
if (options.dcID) {
|
||||||
|
options.dcID = newDcID;
|
||||||
|
} else {
|
||||||
|
AppConfigManager.set({dc: baseDcID = newDcID});
|
||||||
|
}
|
||||||
|
|
||||||
mtpGetNetworker(newDcID).then(function (networker) {
|
mtpGetNetworker(newDcID).then(function (networker) {
|
||||||
networker.wrapApiCall(method, params, options).then(function (result) {
|
networker.wrapApiCall(method, params, options).then(function (result) {
|
||||||
|
Loading…
Reference in New Issue
Block a user