@ -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' } ;