fixed send sms on unregistered number
This commit is contained in:
parent
ca781f6c86
commit
b09a290674
@ -33,12 +33,12 @@
|
||||
|
||||
|
||||
<script type="text/javascript" src="js/lib/config.js"></script>
|
||||
<script type="text/javascript" src="js/lib/mtproto.js?2"></script>
|
||||
<script type="text/javascript" src="js/lib/mtproto.js?3"></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/services.js?6"></script>
|
||||
<script type="text/javascript" src="js/controllers.js?5"></script>
|
||||
<script type="text/javascript" src="js/controllers.js?6"></script>
|
||||
<script type="text/javascript" src="js/filters.js?3"></script>
|
||||
<script type="text/javascript" src="js/directives.js?5"></script>
|
||||
|
||||
|
@ -37,6 +37,16 @@ angular.module('myApp.controllers', [])
|
||||
};
|
||||
|
||||
$scope.sendCode = function () {
|
||||
$scope.progress.enabled = true;
|
||||
MtpApiManager.invokeApi('auth.checkPhone', {
|
||||
phone_number: $scope.credentials.phone_number
|
||||
}, {dcID: dcID}).then(function (result) {
|
||||
$scope.progress.enabled = false;
|
||||
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.');
|
||||
return false;
|
||||
}
|
||||
|
||||
$scope.progress.enabled = true;
|
||||
MtpApiManager.invokeApi('auth.sendCode', {
|
||||
phone_number: $scope.credentials.phone_number,
|
||||
@ -46,26 +56,22 @@ angular.module('myApp.controllers', [])
|
||||
}, {dcID: dcID}).then(function (sentCode) {
|
||||
$scope.progress.enabled = false;
|
||||
|
||||
if (!sentCode.phone_registered) {
|
||||
ErrorService.showSimpleError('No account', 'Sorry, there is no Telegram account for ' + $scope.credentials.phone_number + '. Please sign up using our mobile apps.');
|
||||
return false;
|
||||
}
|
||||
|
||||
$scope.credentials.phone_code_hash = sentCode.phone_code_hash;
|
||||
$scope.credentials.phone_occupied = sentCode.phone_registered;
|
||||
$scope.error = {};
|
||||
|
||||
}, function (error) {
|
||||
$scope.progress.enabled = false;
|
||||
dLog('sendCode', error);
|
||||
if (error.code == 303) {
|
||||
var newDcID = error.type.match(/^(PHONE_MIGRATE_|NETWORK_MIGRATE_)(\d+)/)[2];
|
||||
if (newDcID != dcID) {
|
||||
dcID = newDcID;
|
||||
$scope.sendCode();
|
||||
return;
|
||||
}
|
||||
dLog('sendCode error', error);
|
||||
switch (error.type) {
|
||||
case 'PHONE_NUMBER_INVALID':
|
||||
$scope.error = {field: 'phone'};
|
||||
break;
|
||||
}
|
||||
});
|
||||
}, function (error) {
|
||||
$scope.progress.enabled = false;
|
||||
dLog('checkPhone error', error);
|
||||
switch (error.type) {
|
||||
case 'PHONE_NUMBER_INVALID':
|
||||
$scope.error = {field: 'phone'};
|
||||
|
@ -2240,7 +2240,20 @@ factory('MtpApiManager', function (AppConfigManager, MtpAuthorizer, MtpNetworker
|
||||
}, function (error) {
|
||||
deferred.reject(error);
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else if (error.code == 303) {
|
||||
var newDcID = error.type.match(/^(PHONE_MIGRATE_|NETWORK_MIGRATE_)(\d+)/)[2];
|
||||
if (newDcID != dcID) {
|
||||
mtpGetNetworker(newDcID).then(function (networker) {
|
||||
networker.wrapApiCall(method, params, options).then(function (result) {
|
||||
deferred.resolve(result);
|
||||
}, function (error) {
|
||||
deferred.reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
deferred.reject(error);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user