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');
const GlobalOptions = mongoose.model('SurveyGlobalOptions');
exports.registerNewToken = async (req, res) => {
try {
// try {
const checkToken = await Token.checkExistingField('token', req.body.token);
if (checkToken) {
return res.status(201).json({
......@@ -12,20 +12,29 @@ 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){
console.log(req.body)
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) {
res.status(400).json({ message: err,status:"Error" });
}
// } catch (err) {
// res.status(400).json({ message: err,status:"Error" });
// }
};
exports.update_token = async (req, res) => {
......
{
"name": "api",
"version": "1.1.1",
"version": "1.1.2",
"lockfileVersion": 2,
"requires": true,
"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