This repository has been archived on 2023-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
FoodLoop-Web/pages/login/loginCtrl.js

50 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-03-10 13:26:13 +00:00
app.controller('loginCtrl', function($scope,$state,$http,$rootScope,authService) {
/* login variables */
$scope.username = "user";
$scope.password = "Doe";
$scope.fullName = function() {
return $scope.firstName + " " + $scope.lastName;
};
// 1. send request to server to authenticate login information
// 2. on succeed, redirect to page
// 2.1 on failed, display error message
$scope.signin = function(){
var foodloop_token_url_login = "http://192.168.2.172:3000/login";
var loginData = JSON.stringify({
email : this.username,
password: this.password
});
console.log("Attempting to login in");
$http.post(foodloop_token_url_login,loginData).success(function(repsonse){
console.log("Resolving response from server");
console.log(repsonse.data);
},function(repsonse){
console.log("Ooops, Something went wrong");
});
authService.setUsername($scope.username);
// $state.go("user");
// if($scope.username === "admin"){
// $state.go('admin');
// }
// else if($scope.username === "user"){
// $state.go('user');
// }
// else{
// $state.go('home');
// }
}
$scope.createAccount = function(){
console.log("Create account button clicked");
}
});