Blame view
app/partials/login/login.controller.js
1.27 KB
feacde5ff
|
1 2 3 4 5 |
(function() { 'use strict' angular.module('acufuel') |
4bb02bb84
|
6 |
.controller('LoginController', [ '$scope', '$filter', '$rootScope', '$state', 'LoginService', LoginController]); |
67d43a8c6
|
7 |
|
4bb02bb84
|
8 |
function LoginController($scope, $filter, $rootScope, $state, LoginService) { |
feacde5ff
|
9 |
$scope.data = {}; |
67d43a8c6
|
10 11 12 13 |
$scope.data.username = ''; $scope.data.password = ''; $scope.count = 0; var loginData; |
4bb02bb84
|
14 |
$scope.submitLogin = function() { |
67d43a8c6
|
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
|
34 |
} |
feacde5ff
|
35 36 |
} })(); |