Commit 7ba2cc36 authored by antoine masson's avatar antoine masson
Browse files

v1.08

-fix a bug in poc login token
- remove special char in csv export
-new lang def with FINISH
parent 9ca58d9b
......@@ -132,7 +132,13 @@ exports.downJSON_survey_tokens = async (req,res)=>{
res.status(400).json({ message: err,status:"Error"});
}
};
function removeNonAsciiChars(str){
if(typeof str === 'string'){
str = str.replace(/[^\w\s]/gi, "_");
str = str.replace(/(\r\n|\n|\r)/gm,"");
}
return str;
}
exports.downCSV_survey_tokens = async (req,res)=>{
const { Parser,transforms: { flatten } } = require('json2csv');
try{
......@@ -142,6 +148,10 @@ exports.downCSV_survey_tokens = async (req,res)=>{
let tokensjson=await JSON.parse(JSON.stringify(tokens))
tokensjson.forEach(o=>o.survey_id=survey.general.short_name)
tokensjson.forEach(o=>{delete o.test; delete o.id})
tokensjson.forEach(o=>{ //remove special characters in post and presurvey
if(o.answers.presurvey) Object.keys(o.answers.presurvey).forEach(function(el){o.answers.presurvey[el]=removeNonAsciiChars(o.answers.presurvey[el])});
if(o.answers.postsurvey) Object.keys(o.answers.postsurvey).forEach(function(el){o.answers.postsurvey[el]=removeNonAsciiChars(o.answers.postsurvey[el])});
});
const transforms = [flatten({ paths: ['answers'] })];
const parser = new Parser({transforms});
......@@ -193,7 +203,7 @@ exports.loginToken = async (req, res) => {
if(token.status==="finished"){
return res
.status(201)
.json({ message: "Status : finished" ,poc:survey.poc,status: "Error"});
.json({ message: "Status : finished" ,poc:spoc,status: "Error"});
}
const authtoken = await token.generateAuthToken();
res.status(201).json({ token:authtoken, message : "Succeeded Login", status: "OK"});
......
{
"name": "api",
"version": "1.0.7",
"version": "1.0.8",
"description": "",
"main": "index.js",
"scripts": {
......
This diff is collapsed.
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