mirror of
https://github.com/arnaucube/commonroutesServer.git
synced 2026-02-28 05:26:42 +01:00
delete travel implemented
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#CollectiveCar app
|
#CollectiveCar app
|
||||||
|
|
||||||
|
frontend app code: https://github.com/idoctnef/collectivecarApp
|
||||||
|
|
||||||
**Backend:**
|
**Backend:**
|
||||||
Nodejs + Express + MongoDB
|
Nodejs + Express + MongoDB
|
||||||
|
|||||||
@@ -92,11 +92,11 @@ exports.updateTravel = function(req, res) {
|
|||||||
|
|
||||||
//DELETE
|
//DELETE
|
||||||
exports.deleteTravel = function(req, res) {
|
exports.deleteTravel = function(req, res) {
|
||||||
ActivityModel.findById(req.params.id, function(err, activity) {
|
travelModel.findById(req.params.id, function(err, travel) {
|
||||||
activity.remove(function(err) {
|
travel.remove(function(err) {
|
||||||
if(err) return res.send(500, err.message);
|
if(err) return res.send(500, err.message);
|
||||||
res.status(200).jsonp(req.params.id);
|
res.status(200).jsonp(req.params.id);
|
||||||
console.log('DELETE /activities/' + req.params.id);
|
console.log('DELETE /traves/' + req.params.id);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ exports.login = function(req, res) {
|
|||||||
// create a token
|
// create a token
|
||||||
var token = jwt.sign(user, app.get('superSecret'), {
|
var token = jwt.sign(user, app.get('superSecret'), {
|
||||||
//expiresInMinutes: 1440 // expires in 24 hours
|
//expiresInMinutes: 1440 // expires in 24 hours
|
||||||
expiresIn: '60m'
|
//expiresIn: '60m'
|
||||||
});
|
});
|
||||||
console.log(user);
|
console.log(user);
|
||||||
// return the information including token as JSON
|
// return the information including token as JSON
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ var travelSchema = new Schema({
|
|||||||
phone: { type: Number },
|
phone: { type: Number },
|
||||||
telegram: { type: String },
|
telegram: { type: String },
|
||||||
collectivized: { type: Boolean },
|
collectivized: { type: Boolean },
|
||||||
modality: { type: String } //if is an offering travel or asking for travel
|
modality: { type: String }, //if is an offering travel or asking for travel
|
||||||
|
joinedusers: { type: String },
|
||||||
|
acceptedusers: { type: String }
|
||||||
})
|
})
|
||||||
module.exports = mongoose.model('travelModel', travelSchema);
|
module.exports = mongoose.model('travelModel', travelSchema);
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ apiRoutes.route('/travels')
|
|||||||
.get(travelCtrl.findAllTravels);
|
.get(travelCtrl.findAllTravels);
|
||||||
|
|
||||||
apiRoutes.route('/travels/:id')
|
apiRoutes.route('/travels/:id')
|
||||||
.get(travelCtrl.findById)
|
.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
|
// route middleware to verify a token
|
||||||
@@ -80,7 +80,6 @@ apiRoutes.use(function(req, res, next) {
|
|||||||
|
|
||||||
// decode token
|
// decode token
|
||||||
if (token) {
|
if (token) {
|
||||||
|
|
||||||
// verifies secret and checks exp
|
// verifies secret and checks exp
|
||||||
jwt.verify(token, app.get('superSecret'), function(err, decoded) {
|
jwt.verify(token, app.get('superSecret'), function(err, decoded) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user