Commit cb135ee9 authored by antoine masson's avatar antoine masson
Browse files

Merge branch 'Development' into production

parents 3310def6 04124292
......@@ -12,15 +12,23 @@ exports.registerNewToken = async (req, res) => {
status: "Error"
});
}
const token = new Token({
token: req.body.token,
survey_id: req.body.survey_id,
enable: req.body.enable,
status:"new",
access:false,
comments:req.body.comments,
test:req.body.test,
});
let token;
if(req.body.advanced){
delete req.body.advanced
token = new Token(req.body)
} else {
delete req.body.advanced
token = new Token({
token: req.body.token,
survey_id: req.body.survey_id,
enable: req.body.enable,
status:"new",
access:false,
comments:req.body.comments,
test:req.body.test,
});
}
const newtoken = await token.save();
res.status(201).json({token:newtoken,message:"Token created",status: "OK"});
} catch (err) {
......@@ -88,10 +96,11 @@ exports.get_a_token = async (req, res) => {
exports.update_a_token = async (req, res) => {
try {
const token = await Token.findOne({ _id: req.params.id });
let oldstatus=token.status;
for (key in req.body) {
token[key] = req.body[key];
}
if(token.status==='new'){
if(token.status==='new'&&oldstatus!=='new'){
token.answers=null
token.submitedAt=null
}
......
{
"name": "api",
"version": "1.1.1",
"version": "1.1.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
......
{
"name": "api",
"version": "1.1.2",
"version": "1.1.3",
"description": "",
"main": "index.js",
"scripts": {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment