Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('newApp2App').controller('loginCtrl', function ($scope, authService, $translate, camerasService, userService, $state, startStateService, notificationService) {
- $scope.loginData = {
- userName: "",
- password: ""
- };
- var lastLoginTry = new Date(0);
- $scope.message = "";
- $scope.login = function () {
- var currentData = new Date();
- var difference = (currentData - lastLoginTry) / 1000;
- if (difference > 10) {
- lastLoginTry = currentData;
- authService.login($scope.loginData).then(
- function (response) {
- notificationService.clearNotifications();
- startStateService.getStartStateName().then(
- function (stateName)
- {
- $state.go(stateName);
- });
- if($scope.$close)
- {
- $scope.$close();
- }
- },
- function (err)
- {
- $scope.message = $translate.instant(err.error_description);
- $scope.loginData.password = "";
- }
- );
- }
- else {
- var seconds = Math.round(10 - difference) + 1;
- $scope.message = $translate.instant('TOOOFTENLOGIN') + seconds + $translate.instant('TOOOFTENLOGINSECOND');
- //$scope.loginData.password = "";
- }
- };
- $scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams){
- if($scope.$close)
- {
- $scope.$close();
- }
- })
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement