Skip to content

Commit

Permalink
Merge pull request #12 from MeeraChandrasekaran/master
Browse files Browse the repository at this point in the history
made login work
  • Loading branch information
DavidJDJ committed Oct 4, 2015
2 parents 407e65b + ab2f973 commit 7337266
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
1 change: 0 additions & 1 deletion client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<script src="routes.js"></script>
<script src="./js/homeController.js"></script>
<script src="./js/newKidController.js"></script>
<script src="./js/loginController.js"></script>
</head>
<body>
<div ng-view="">
Expand Down
4 changes: 2 additions & 2 deletions client/js/homeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ saburiKonnect.controller('homeController', function($scope, $location, NewOrgani

$scope.login = function()
{
console.log(NewOrganisationFactory);
NewOrganisationFactory.login($scope.orgLogin);
};

Expand All @@ -190,7 +189,8 @@ saburiKonnect.controller('homeController', function($scope, $location, NewOrgani
var factory = {};
factory.login = function(info,callback){
$http.post('/login', info).success(function(output){
callback(output);
console.log(output);
// callback(output);
});
};
factory.add_Organisation = function(info,callback){
Expand Down
4 changes: 2 additions & 2 deletions client/partials/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ <h4 class="modal-title" id="myModalLabel">Login</h4>
<label>Email</label>
<input type="text" ng-model="orgLogin.email"><br>
<label>Password</label>
<input type="text" ng-model="orgLogin.password">
<input type="password" ng-model="orgLogin.password">
</form>
</div>
<div class="modal-footer">
Expand Down Expand Up @@ -136,7 +136,7 @@ <h4 class="modal-title" id="myModalLabel">Register</h4>
<label>Email</label>
<input type="text" ng-model="organisation.email"><br>
<label>Password</label>
<input type="text" ng-model="organisation.password"><br>
<input type="password" ng-model="organisation.password"><br>
<label>Contact Number</label>
<input type="text" ng-model="organisation.contact_number">
</div>
Expand Down
4 changes: 4 additions & 0 deletions config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ module.exports = function(app){
app.post('/add_organisation',function(req,res){
organisations.add_organisation(req,res)
});

app.post('/login',function(req,res){
organisations.login(req,res)
});
}


17 changes: 17 additions & 0 deletions server/controllers/organisations.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ module.exports = (function(){
res.redirect('');
}
});
},

login: function(req,res){
organisation.find({},function(err,results){
if(err){
console.log('error');
}else{
for(var i=0;i<results.length;i++){
if(results[i].email == req.body.email){
console.log('found user');
res.json(results[i]);
}else{
console.log('user not found');
}
}
}
})
}
};
})();
Expand Down

0 comments on commit 7337266

Please sign in to comment.