@ -38,34 +38,40 @@ angular.module('myApp.controllers', [])
@@ -38,34 +38,40 @@ angular.module('myApp.controllers', [])
$scope . sendCode = function ( ) {
$scope . progress . enabled = true ;
MtpApiManager . invokeApi ( 'auth.sendCode' , {
phone _number : $scope . credentials . phone _number ,
sms _type : 0 ,
api _id : 2496 ,
api _hash : '8da85b0d5bfe62527e5b244c209159c3'
} , { dcID : dcID } ) . then ( function ( sentCode ) {
MtpApiManager . invokeApi ( 'auth.checkPhone' , {
phone _number : $scope . credentials . phone _number
} , { dcID : dcID } ) . then ( function ( result ) {
$scope . progress . enabled = false ;
if ( ! sentCode . 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.' ) ;
return false ;
}
$scope . credentials . phone _code _hash = sentCode . phone _code _hash ;
$scope . credentials . phone _occupied = sentCode . phone _registered ;
$scope . error = { } ;
$scope . progress . enabled = true ;
MtpApiManager . invokeApi ( 'auth.sendCode' , {
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 ) {
$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 ( 'checkPhone error' , error ) ;
switch ( error . type ) {
case 'PHONE_NUMBER_INVALID' :
$scope . error = { field : 'phone' } ;