Commit 6e6a7b83 authored by antoine masson's avatar antoine masson
Browse files

v1.14

- Add advanced mode for creating token
parent f4ede89b
...@@ -4,7 +4,7 @@ const Survey = mongoose.model('Survey'); ...@@ -4,7 +4,7 @@ const Survey = mongoose.model('Survey');
const GlobalOptions = mongoose.model('SurveyGlobalOptions'); const GlobalOptions = mongoose.model('SurveyGlobalOptions');
exports.registerNewToken = async (req, res) => { exports.registerNewToken = async (req, res) => {
try { // try {
const checkToken = await Token.checkExistingField('token', req.body.token); const checkToken = await Token.checkExistingField('token', req.body.token);
if (checkToken) { if (checkToken) {
return res.status(201).json({ return res.status(201).json({
...@@ -12,20 +12,29 @@ exports.registerNewToken = async (req, res) => { ...@@ -12,20 +12,29 @@ exports.registerNewToken = async (req, res) => {
status: "Error" status: "Error"
}); });
} }
const token = new Token({ let token;
token: req.body.token, if(req.body.advanced){
survey_id: req.body.survey_id, console.log(req.body)
enable: req.body.enable, delete req.body.advanced
status:"new", token = new Token(req.body)
access:false, } else {
comments:req.body.comments, delete req.body.advanced
test:req.body.test, 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(); const newtoken = await token.save();
res.status(201).json({token:newtoken,message:"Token created",status: "OK"}); res.status(201).json({token:newtoken,message:"Token created",status: "OK"});
} catch (err) { // } catch (err) {
res.status(400).json({ message: err,status:"Error" }); // res.status(400).json({ message: err,status:"Error" });
} // }
}; };
exports.update_token = async (req, res) => { exports.update_token = async (req, res) => {
......
{ {
"name": "api", "name": "api",
"version": "1.1.1", "version": "1.1.2",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
......
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