Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
swing-webapp
api
Commits
cb135ee9
Commit
cb135ee9
authored
Jul 09, 2021
by
antoine masson
Browse files
Merge branch 'Development' into production
parents
3310def6
04124292
Changes
3
Hide whitespace changes
Inline
Side-by-side
controllers/TokenController.js
View file @
cb135ee9
...
...
@@ -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
}
...
...
package-lock.json
View file @
cb135ee9
{
"name"
:
"api"
,
"version"
:
"1.1.
1
"
,
"version"
:
"1.1.
2
"
,
"lockfileVersion"
:
2
,
"requires"
:
true
,
"packages"
:
{
...
...
package.json
View file @
cb135ee9
{
"name"
:
"api"
,
"version"
:
"1.1.
2
"
,
"version"
:
"1.1.
3
"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment