Skip to content
Permalink
0f924d8336
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
49 lines (42 sloc) 1.5 KB
// This controller will hold logic for the employee Portal homepage (Order List, Logout), Customer Info, Media Center, and Reports
angular.module('routerApp').controller('adminController', function($scope, $http, $log, $timeout, $cookies,urlService,$anchorScroll,$location,$q,$state,$rootScope) {
/* Retrieve Url */
var url = urlService.web;
$cookies.put('PAGE','Admin');
/* Functions Defined */
$scope.authenticateAdmin = function(id,pass){
console.log("Authenticating");
return $q(function(resolve,reject){
var param = id + " " + pass;
var promise = $http.post(url + "/authenticateAdmin",param)
.success(function(data) {
if (data.STATUS == 555) {
$scope.authenticated = false;
resolve('We did it');
} else {
$scope.authenticated = true;
resolve('We did it');
}
})
.error(function(data, status, headers, config) {
$scope.messages = 'There was a network error. Try again later.';
reject('We did not do it');
});
})
}
$scope.logoutAdmin = function(){
$scope.messages = 'You have been logged out.';
$cookies.remove("PWD");
$cookies.remove("ADMIN");
$cookies.remove("LOGIN");
$state.go('home');
}
/* BEGIN LOGIC */
var promise = $scope.authenticateAdmin($cookies.get('ADMIN'),$cookies.get('PWD'));
promise.then(function(){
if($scope.authenticated == true){
$scope.initAdmin();
}
else if ($scope.authenticated == false)$scope.logoutAdmin();
});
});