Blame view

app/partials/login/login.controller.js 1.27 KB
feacde5ff   Rishav   setup acuefuel in...
1
2
3
4
5
  
  (function() {
      'use strict'
      
      angular.module('acufuel')
4bb02bb84   Rishav   new integration w...
6
          .controller('LoginController', [ '$scope', '$filter', '$rootScope', '$state', 'LoginService', LoginController]);
67d43a8c6   Kuldeep Arora   login page update
7
     
4bb02bb84   Rishav   new integration w...
8
      function LoginController($scope, $filter, $rootScope, $state, LoginService) {
feacde5ff   Rishav   setup acuefuel in...
9
      	$scope.data = {};
67d43a8c6   Kuldeep Arora   login page update
10
11
12
13
        $scope.data.username = '';
        $scope.data.password = '';
        $scope.count = 0;
        var loginData;
4bb02bb84   Rishav   new integration w...
14
        $scope.submitLogin = function() {
67d43a8c6   Kuldeep Arora   login page update
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
            loginData = "username=" + $scope.data.username + "&password=" + $scope.data.password;
            if ($scope.data.username !== '' && $scope.data.password !== '' && $scope.data.username !== undefined && $scope.data.password !== undefined) {
              if ($scope.count === 0) {
                $scope.count++
                LoginService.loginUser(loginData).then(function(result) {
                    if(result.status == 200){
                      LoginService.authenticate();
                    }else{
                      toastr.error('Username or password incorrect.', {
                        closeButton: true
                      })
                    }
                })
              }
            }else{
              toastr.error('Please enter username & password.', {
                closeButton: true
              })
            }
4bb02bb84   Rishav   new integration w...
34
        }
feacde5ff   Rishav   setup acuefuel in...
35
36
      }
  })();