0
私はangle + node js appを書いています。httpのポストコールを使ってユーザとパスワードを検証するloginメソッドを持っています:
私はの価値を持っている私のlogin.jsファイルでただし、userloginのfuctionを持つようにしたいapp.post('/authenticate_user', function(req, res){
authenticate_user(req, res);
});
var authenticate_user=function(req, res){
var query= user_details.find({'name': req.body.name});
res.setHeader("Cache-Control", "private, no-cache, no-store, must-revalidate, max-age=0");
query.exec(function(err, docs){
if (docs.length==0) return false;
res.json(docs[0].password==req.body.password);
});
}
を:私はauthneticationを処理していますserver.jsファイルの
login.js
$scope.userLogin = function (info) {
$http.post('/authenticate_user', {'name':info.name,'password':info.password})
.success(function(data) {
})
.error(function(data) {
console.log('Error:'+ data);
});
}
app.post()メソッド..
私はlogin.jsファイルで呼び出し元のメソッドに転送する私のAPIのポストから値を持つようにしたい
$http.post('/authenticate_user', {'name':info.name,'password':info.password})
.success(function(data) {
// what is data includes here? the response for the http post?
// or what the function I calling to aka authenticate_user, returns - in this case - a boolean value?
})
ような何か...
それを行う方法上の任意のアイデア?
おかげ