comprovació de token activada al server, falta afegir headers als request de la app

This commit is contained in:
nau
2016-08-28 21:07:36 +02:00
parent 049492ca1a
commit 7e313047f1
2 changed files with 21 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
//var urlapi="http://localhost:3000/api/";
var urlapi="http://192.168.1.40:3000/api/";
var urlapi="http://localhost:3000/api/";
//var urlapi="http://192.168.1.40:3000/api/";
//localStorage.setItem("c_username", "user2");
//localStorage.setItem("c_token", "");
@@ -77,6 +77,7 @@ angular.module('starter.controllers', [])
},
function(response) { // optional
// failed
console.log(response);
});
};
@@ -110,7 +111,7 @@ angular.module('starter.controllers', [])
})
.controller('TravelsCtrl', function($scope, $http, $ionicModal, $timeout) {
.controller('TravelsCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading) {
$scope.travels="";
$scope.travels=JSON.parse(localStorage.getItem('c_travels'));
@@ -130,6 +131,7 @@ angular.module('starter.controllers', [])
})
.then(function(result){
travels = result.data;
$ionicLoading.show({ template: 'Travels actualized from server!', noBackdrop: true, duration: 2000 });
});
};
@@ -200,6 +202,10 @@ angular.module('starter.controllers', [])
$scope.newtravel._id=response.data._id;
$scope.travels.push($scope.newtravel);
$scope.newtravel={};
if(response.data.success==false){
$ionicLoading.show({ template: 'failed to generate new travel', noBackdrop: true, duration: 2000 });
}
},
function(response) { // optional
// failed
@@ -231,6 +237,10 @@ angular.module('starter.controllers', [])
console.log(response);
$scope.newtravel._id=response.data._id;
$scope.travels.push($scope.newtravel);
if(response.data.success==false){
$ionicLoading.show({ template: 'failed to generate new asking travel', noBackdrop: true, duration: 2000 });
}
},
function(response) { // optional
// failed
@@ -263,6 +273,10 @@ angular.module('starter.controllers', [])
console.log(response);
$scope.newtravel._id=response.data._id;
$scope.travels.push($scope.newtravel);
if(response.data.success==false){
$ionicLoading.show({ template: 'failed to generate new asking package', noBackdrop: true, duration: 2000 });
}
},
function(response) { // optional
// failed

View File

@@ -71,7 +71,7 @@ apiRoutes.route('/travels')
apiRoutes.route('/travels/:id')
.get(travelCtrl.findById)
/* OJU AQUÏ TREC la verificació de token temporalment, per fer les proves des de l'app
// OJU AQUÏ TREC la verificació de token temporalment, per fer les proves des de l'app
// route middleware to verify a token
apiRoutes.use(function(req, res, next) {
@@ -96,13 +96,14 @@ apiRoutes.use(function(req, res, next) {
// if there is no token
// return an error
return res.status(403).send({
return res.status(201).send({
success: false,
message: 'No token provided.'
});
}
});*/
}); //fi verificació de token
apiRoutes.route('/users/:id')
.put(userCtrl.updateUser)