Added login sendCall support
This commit is contained in:
parent
a6ad08b6a7
commit
9ce0f9687c
@ -51,9 +51,9 @@
|
||||
<script type="text/javascript" src="js/lib/mtproto.js?17"></script>
|
||||
|
||||
<script type="text/javascript" src="js/util.js"></script>
|
||||
<script type="text/javascript" src="js/app.js?8"></script>
|
||||
<script type="text/javascript" src="js/app.js?9"></script>
|
||||
<script type="text/javascript" src="js/services.js?12"></script>
|
||||
<script type="text/javascript" src="js/controllers.js?16"></script>
|
||||
<script type="text/javascript" src="js/controllers.js?17"></script>
|
||||
<script type="text/javascript" src="js/filters.js?3"></script>
|
||||
<script type="text/javascript" src="js/directives.js?10"></script>
|
||||
|
||||
|
@ -54,7 +54,7 @@ config(['$locationProvider', '$routeProvider', '$compileProvider', function($loc
|
||||
|
||||
// $locationProvider.html5Mode(true);
|
||||
$routeProvider.when('/', {templateUrl: 'partials/welcome.html?2', controller: 'AppWelcomeController'});
|
||||
$routeProvider.when('/login', {templateUrl: 'partials/login.html?2', controller: 'AppLoginController'});
|
||||
$routeProvider.when('/login', {templateUrl: 'partials/login.html?3', controller: 'AppLoginController'});
|
||||
$routeProvider.when('/im', {templateUrl: 'partials/im.html?6', controller: 'AppIMController', reloadOnSearch: false});
|
||||
$routeProvider.otherwise({redirectTo: '/'});
|
||||
|
||||
|
@ -21,22 +21,42 @@ angular.module('myApp.controllers', [])
|
||||
});
|
||||
})
|
||||
|
||||
.controller('AppLoginController', function ($scope, $location, MtpApiManager, ErrorService) {
|
||||
.controller('AppLoginController', function ($scope, $location, $timeout, MtpApiManager, ErrorService) {
|
||||
var options = {dcID: 1};
|
||||
|
||||
$scope.credentials = {};
|
||||
$scope.progress = {};
|
||||
$scope.callPending = {};
|
||||
|
||||
var callTimeout;
|
||||
|
||||
function saveAuth (result) {
|
||||
MtpApiManager.setUserAuth(options.dcID, {
|
||||
expires: result.expires,
|
||||
id: result.user.id
|
||||
});
|
||||
$timeout.cancel(callTimeout);
|
||||
|
||||
$location.url('/im');
|
||||
};
|
||||
|
||||
function callCheck () {
|
||||
$timeout.cancel(callTimeout);
|
||||
if (!(--$scope.callPending.remaining)) {
|
||||
$scope.callPending.success = false;
|
||||
MtpApiManager.invokeApi('auth.sendCall', {
|
||||
phone_number: $scope.credentials.phone_number,
|
||||
phone_code_hash: $scope.credentials.phone_code_hash
|
||||
}).then(function () {
|
||||
$scope.callPending.success = true;
|
||||
});
|
||||
} else {
|
||||
callTimeout = $timeout(callCheck, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
$scope.sendCode = function () {
|
||||
$timeout.cancel(callTimeout);
|
||||
$scope.progress.enabled = true;
|
||||
MtpApiManager.invokeApi('auth.checkPhone', {
|
||||
phone_number: $scope.credentials.phone_number
|
||||
@ -60,6 +80,9 @@ angular.module('myApp.controllers', [])
|
||||
$scope.credentials.phone_occupied = sentCode.phone_registered;
|
||||
$scope.error = {};
|
||||
|
||||
$scope.callPending.remaining = 10;
|
||||
callCheck();
|
||||
|
||||
}, function (error) {
|
||||
$scope.progress.enabled = false;
|
||||
console.log('sendCode error', error);
|
||||
|
@ -20,6 +20,12 @@
|
||||
<h3 class="login_form_head">{{ credentials.phone_number | phoneNumber }} <small>(<a href="#/auth">edit</a>)</small></h3>
|
||||
<p class="login_form_lead">We have sent you a code via SMS.<br/>Please enter it below.</p>
|
||||
|
||||
<p class="login_form_lead">
|
||||
<span ng-show="callPending.remaining > 0">Telegram will call you in {{callPending.remaining | duration}}</span>
|
||||
<span ng-show="!callPending.remaining && !callPending.success">Telegram is calling you</span>
|
||||
<span ng-show="!callPending.remaining && callPending.success">Telegram dialed your number</span>
|
||||
</p>
|
||||
|
||||
<div class="form-group" ng-class="{'has-error': error.field == 'phone_code'}">
|
||||
<label class="control-label" for="phone_code" ng-if="error.field == 'phone_code'">Incorrect SMS code</label>
|
||||
<input type="text" class="form-control" name="phone_code" ng-model="credentials.phone_code" placeholder="Enter your code" required>
|
||||
|
Loading…
x
Reference in New Issue
Block a user