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/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/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?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/filters.js?3"></script>
|
||||||
<script type="text/javascript" src="js/directives.js?5"></script>
|
<script type="text/javascript" src="js/directives.js?5"></script>
|
||||||
|
|
||||||
|
@ -38,34 +38,40 @@ angular.module('myApp.controllers', [])
|
|||||||
|
|
||||||
$scope.sendCode = function () {
|
$scope.sendCode = function () {
|
||||||
$scope.progress.enabled = true;
|
$scope.progress.enabled = true;
|
||||||
MtpApiManager.invokeApi('auth.sendCode', {
|
MtpApiManager.invokeApi('auth.checkPhone', {
|
||||||
phone_number: $scope.credentials.phone_number,
|
phone_number: $scope.credentials.phone_number
|
||||||
sms_type: 0,
|
}, {dcID: dcID}).then(function (result) {
|
||||||
api_id: 2496,
|
|
||||||
api_hash: '8da85b0d5bfe62527e5b244c209159c3'
|
|
||||||
}, {dcID: dcID}).then(function (sentCode) {
|
|
||||||
$scope.progress.enabled = false;
|
$scope.progress.enabled = false;
|
||||||
|
if (!result.phone_registered) {
|
||||||
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.');
|
ErrorService.showSimpleError('No account', 'Sorry, there is no Telegram account for ' + $scope.credentials.phone_number + '. Please sign up using our mobile apps.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.credentials.phone_code_hash = sentCode.phone_code_hash;
|
$scope.progress.enabled = true;
|
||||||
$scope.credentials.phone_occupied = sentCode.phone_registered;
|
MtpApiManager.invokeApi('auth.sendCode', {
|
||||||
$scope.error = {};
|
phone_number: $scope.credentials.phone_number,
|
||||||
|
sms_type: 0,
|
||||||
|
api_id: 2496,
|
||||||
|
api_hash: '8da85b0d5bfe62527e5b244c209159c3'
|
||||||
|
}, {dcID: dcID}).then(function (sentCode) {
|
||||||
|
$scope.progress.enabled = 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', error);
|
||||||
|
switch (error.type) {
|
||||||
|
case 'PHONE_NUMBER_INVALID':
|
||||||
|
$scope.error = {field: 'phone'};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
$scope.progress.enabled = false;
|
$scope.progress.enabled = false;
|
||||||
dLog('sendCode', error);
|
dLog('checkPhone error', error);
|
||||||
if (error.code == 303) {
|
|
||||||
var newDcID = error.type.match(/^(PHONE_MIGRATE_|NETWORK_MIGRATE_)(\d+)/)[2];
|
|
||||||
if (newDcID != dcID) {
|
|
||||||
dcID = newDcID;
|
|
||||||
$scope.sendCode();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch (error.type) {
|
switch (error.type) {
|
||||||
case 'PHONE_NUMBER_INVALID':
|
case 'PHONE_NUMBER_INVALID':
|
||||||
$scope.error = {field: 'phone'};
|
$scope.error = {field: 'phone'};
|
||||||
|
@ -2240,7 +2240,20 @@ factory('MtpApiManager', function (AppConfigManager, MtpAuthorizer, MtpNetworker
|
|||||||
}, function (error) {
|
}, function (error) {
|
||||||
deferred.reject(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);
|
deferred.reject(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user