This commit is contained in:
Lukas F. Hartmann
2018-05-01 17:06:29 +02:00
16 changed files with 16610 additions and 154 deletions

View File

@@ -25,7 +25,10 @@ router.post('/', function(req, res) {
res.sendStatus(404);
})
.then(user => {
if (bcrypt.compareSync(password, user.password_hash)) {
if (!user) {
res.sendStatus(404);
}
else if (bcrypt.compareSync(password, user.password_hash)) {
crypto.randomBytes(48, function(ex, buf) {
var token = buf.toString('hex');

View File

@@ -53,15 +53,8 @@ router.get('/', (req, res) => {
space_id: req.space._id
}}).then(artifacts => {
async.map(artifacts, (a, cb) => {
//a = a.toObject(); TODO
db.unpackArtifact(a);
if (a.control_points) {
a.control_points = JSON.parse(a.control_points);
}
if (a.payload_alternatives) {
a.payload_alternatives = JSON.parse(a.payload_alternatives);
}
if (a.user_id) {
// FIXME JOIN
/*User.findOne({where: {
@@ -131,7 +124,8 @@ router.post('/:artifact_id/payload', function(req, res, next) {
var stream = req.pipe(writeStream);
var progress_callback = function(progress_msg) {
a.description = progress_msg;
a.description = progress_msg.toString();
db.packArtifact(a);
a.save();
redis.sendMessage("update", a, JSON.stringify(a), req.channelId);
};

View File

@@ -3,6 +3,7 @@
var config = require('config');
const db = require('../../models/db');
const uuidv4 = require('uuid/v4');
const os = require('os');
var mailer = require('../../helpers/mailer');
var uploader = require('../../helpers/uploader');
@@ -222,8 +223,8 @@ router.post('/:user_id/avatar', (req, res, next) => {
const user = req.user;
const filename = "u"+req.user._id+"_"+(new Date().getTime())+".jpeg"
const localFilePath = "/tmp/"+filename;
const localResizedFilePath = "/tmp/resized_"+filename;
const localFilePath = os.tmpdir()+"/"+filename;
const localResizedFilePath = os.tmpdir()+"/resized_"+filename;
const writeStream = fs.createWriteStream(localFilePath);
const stream = req.pipe(writeStream);