|
|
@ -235,6 +235,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
$scope.credentials.type = sentCode.type |
|
|
|
$scope.credentials.type = sentCode.type |
|
|
|
$scope.nextPending.type = sentCode.next_type || false |
|
|
|
$scope.nextPending.type = sentCode.next_type || false |
|
|
|
$scope.nextPending.remaining = sentCode.timeout || false |
|
|
|
$scope.nextPending.remaining = sentCode.timeout || false |
|
|
|
|
|
|
|
delete $scope.nextPending.progress |
|
|
|
|
|
|
|
|
|
|
|
nextTimeoutCheck() |
|
|
|
nextTimeoutCheck() |
|
|
|
|
|
|
|
|
|
|
@ -248,6 +249,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
$scope.nextPending.remaining > 0) { |
|
|
|
$scope.nextPending.remaining > 0) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$scope.nextPending.progress = true |
|
|
|
MtpApiManager.invokeApi('auth.resendCode', { |
|
|
|
MtpApiManager.invokeApi('auth.resendCode', { |
|
|
|
phone_number: $scope.credentials.phone_full, |
|
|
|
phone_number: $scope.credentials.phone_full, |
|
|
|
phone_code_hash: $scope.credentials.phone_code_hash |
|
|
|
phone_code_hash: $scope.credentials.phone_code_hash |
|
|
@ -260,10 +262,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
$scope.nextPending.remaining === false) { |
|
|
|
$scope.nextPending.remaining === false) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
if (!(--$scope.nextPending.remaining)) { |
|
|
|
if ((--$scope.nextPending.remaining) > 0) { |
|
|
|
$scope.nextPending.success = false |
|
|
|
|
|
|
|
$scope.sendNext() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
nextTimeout = $timeout(nextTimeoutCheck, 1000) |
|
|
|
nextTimeout = $timeout(nextTimeoutCheck, 1000) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -283,7 +282,6 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
delete $scope.credentials.phone_unoccupied |
|
|
|
delete $scope.credentials.phone_unoccupied |
|
|
|
delete $scope.credentials.phone_code_valid |
|
|
|
delete $scope.credentials.phone_code_valid |
|
|
|
delete $scope.nextPending.remaining |
|
|
|
delete $scope.nextPending.remaining |
|
|
|
delete $scope.nextPending.success |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$scope.$watch('credentials.phone_code', function (newVal) { |
|
|
|
$scope.$watch('credentials.phone_code', function (newVal) { |
|
|
@ -297,6 +295,10 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
$scope.logIn = function (forceSignUp) { |
|
|
|
$scope.logIn = function (forceSignUp) { |
|
|
|
|
|
|
|
if ($scope.progress.enabled && |
|
|
|
|
|
|
|
$scope.progress.forceSignUp == forceSignUp) { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
var method = 'auth.signIn' |
|
|
|
var method = 'auth.signIn' |
|
|
|
var params = { |
|
|
|
var params = { |
|
|
|
phone_number: $scope.credentials.phone_full, |
|
|
|
phone_number: $scope.credentials.phone_full, |
|
|
@ -311,6 +313,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.progress.forceSignUp = forceSignUp; |
|
|
|
$scope.progress.enabled = true |
|
|
|
$scope.progress.enabled = true |
|
|
|
MtpApiManager.invokeApi(method, params, options).then(saveAuth, function (error) { |
|
|
|
MtpApiManager.invokeApi(method, params, options).then(saveAuth, function (error) { |
|
|
|
$scope.progress.enabled = false |
|
|
|
$scope.progress.enabled = false |
|
|
@ -358,7 +361,9 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$scope.checkPassword = function () { |
|
|
|
$scope.checkPassword = function () { |
|
|
|
|
|
|
|
$scope.progress.enabled = true |
|
|
|
return PasswordManager.check($scope.password, $scope.credentials.password, options).then(saveAuth, function (error) { |
|
|
|
return PasswordManager.check($scope.password, $scope.credentials.password, options).then(saveAuth, function (error) { |
|
|
|
|
|
|
|
$scope.progress.enabled = false |
|
|
|
switch (error.type) { |
|
|
|
switch (error.type) { |
|
|
|
case 'PASSWORD_HASH_INVALID': |
|
|
|
case 'PASSWORD_HASH_INVALID': |
|
|
|
$scope.error = {field: 'password'} |
|
|
|
$scope.error = {field: 'password'} |
|
|
@ -416,7 +421,13 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
delete $scope.progress.enabled |
|
|
|
delete $scope.progress.enabled |
|
|
|
delete $scope.credentials.password_needed |
|
|
|
delete $scope.credentials.password_needed |
|
|
|
$scope.credentials.phone_unoccupied = true |
|
|
|
$scope.credentials.phone_unoccupied = true |
|
|
|
}, function () { |
|
|
|
}, function (error) { |
|
|
|
|
|
|
|
if (error.type && |
|
|
|
|
|
|
|
error.type.substr(0, 17) == '2FA_CONFIRM_WAIT_') { |
|
|
|
|
|
|
|
error.waitTime = error.type.substr(17) |
|
|
|
|
|
|
|
error.type = '2FA_CONFIRM_WAIT_TIME' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
delete $scope.progress.enabled |
|
|
|
delete $scope.progress.enabled |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|