web i server: login, post thought, get thoughts

This commit is contained in:
nau
2016-08-21 20:57:24 +02:00
parent ab562292cc
commit 21d8768a09
18 changed files with 890 additions and 100 deletions

View File

@@ -54,7 +54,8 @@ exports.addThought = function(req, res) {
var thought = new thoughtModel({
time: req.body.time,
content: req.body.content,
user_id: req.body.user_id
username: req.body.username,
avatar: req.body.avatar
});
thought.save(function(err, thought) {

View File

@@ -59,7 +59,7 @@ exports.addUser = function(req, res) {
username: req.body.username,
password: req.body.password,
description: req.body.description,
icon: req.body.icon,
avatar: req.body.avatar,
mail: req.body.mail,
admin: req.body.admin
});
@@ -124,12 +124,13 @@ exports.login = function(req, res) {
//expiresInMinutes: 1440 // expires in 24 hours
expiresIn: '60m'
});
console.log(user);
// return the information including token as JSON
res.json({
success: true,
message: 'Enjoy your token!',
token: token
token: token,
avatar: user.avatar
});
}