mirror of
https://github.com/arnaucube/commonroutesServer.git
synced 2026-02-28 05:26:42 +01:00
routes
This commit is contained in:
@@ -53,7 +53,7 @@ exports.addTravel = function(req, res) {
|
|||||||
seats: req.body.seats,
|
seats: req.body.seats,
|
||||||
package: req.body.package,
|
package: req.body.package,
|
||||||
collectivized: req.body.collectivized,
|
collectivized: req.body.collectivized,
|
||||||
type: req.body.modality
|
type: req.body.type
|
||||||
});
|
});
|
||||||
|
|
||||||
travel.save(function(err, travel) {
|
travel.save(function(err, travel) {
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ exports.getAllUsers = function(req, res) {
|
|||||||
exports.getUserById = function (req, res) {
|
exports.getUserById = function (req, res) {
|
||||||
userModel.findOne({_id: req.params.userid})
|
userModel.findOne({_id: req.params.userid})
|
||||||
.lean()
|
.lean()
|
||||||
.populate('travels', 'title from to date')
|
.populate('travels', 'title from to date type')
|
||||||
.exec(function (err, user) {
|
.exec(function (err, user) {
|
||||||
if (err) return res.send(500, err.message);
|
if (err) return res.send(500, err.message);
|
||||||
if (!user) {
|
if (!user) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ var userSchema = new Schema({
|
|||||||
password: { type: String, required: true, selected: false },
|
password: { type: String, required: true, selected: false },
|
||||||
token: { type: String, selected: false },
|
token: { type: String, selected: false },
|
||||||
description: { type: String, default: "Hello world" },
|
description: { type: String, default: "Hello world" },
|
||||||
avatar: { type: String, default: "racoon" },
|
avatar: { type: String, default: "img/avatars/racoon.png" },
|
||||||
email: { type: String, required: true },
|
email: { type: String, required: true },
|
||||||
phone: { type: String },
|
phone: { type: String },
|
||||||
telegram: { type: String },
|
telegram: { type: String },
|
||||||
|
|||||||
@@ -81,7 +81,8 @@ apiRoutes.use(function(req, res, next) {
|
|||||||
// 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) {
|
||||||
return res.json({
|
return res.send(204,
|
||||||
|
{
|
||||||
success: false,
|
success: false,
|
||||||
message: 'Failed to authenticate token.'
|
message: 'Failed to authenticate token.'
|
||||||
});
|
});
|
||||||
@@ -97,7 +98,7 @@ apiRoutes.use(function(req, res, next) {
|
|||||||
|
|
||||||
// if there is no token
|
// if there is no token
|
||||||
// return an error
|
// return an error
|
||||||
return res.status(201).send({
|
return res.status(204).send({
|
||||||
success: false,
|
success: false,
|
||||||
message: 'No token provided.'
|
message: 'No token provided.'
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user