Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
simcaq-node
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
simcaq
simcaq-node
Commits
d6f3af11
There was a problem fetching the pipeline summary.
Commit
d6f3af11
authored
8 years ago
by
Lucas Gabriel Lima
Browse files
Options
Downloads
Patches
Plain Diff
update API response for missing fields
parent
e1a94382
No related branches found
No related tags found
2 merge requests
!116
Release v1.0.0
,
!25
Auth
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libs/routes/user.js
+60
-11
60 additions, 11 deletions
src/libs/routes/user.js
with
60 additions
and
11 deletions
src/libs/routes/user.js
+
60
−
11
View file @
d6f3af11
...
@@ -22,33 +22,81 @@ function emailSyntax(email) {
...
@@ -22,33 +22,81 @@ function emailSyntax(email) {
userApp
.
post
(
'
/
'
,
(
req
,
res
,
next
)
=>
{
userApp
.
post
(
'
/
'
,
(
req
,
res
,
next
)
=>
{
if
(
!
req
.
body
.
email
)
{
if
(
!
req
.
body
.
email
)
{
res
.
json
({
success
:
false
,
msg
:
'
Please pass email
.
'
});
res
.
json
({
success
:
false
,
msg
:
'
O campo Email é obrigatório
.
'
});
}
else
{
}
else
{
next
();
next
();
}
}
},
(
req
,
res
,
next
)
=>
{
},
(
req
,
res
,
next
)
=>
{
if
(
!
req
.
body
.
password
)
{
if
(
!
req
.
body
.
password
)
{
res
.
json
({
success
:
false
,
msg
:
'
Please pass password
.
'
});
res
.
json
({
success
:
false
,
msg
:
'
O campo Senha é obrigatório
.
'
});
}
else
{
}
else
{
next
();
next
();
}
}
},
(
req
,
res
,
next
)
=>
{
},
(
req
,
res
,
next
)
=>
{
if
(
!
emailSyntax
(
req
.
body
.
email
)){
if
(
!
emailSyntax
(
req
.
body
.
email
)){
res
.
json
({
success
:
false
,
msg
:
'
Invalid email syntax
.
'
});
res
.
json
({
success
:
false
,
msg
:
'
O email Informado é inválido
.
'
});
}
else
{
}
else
{
next
();
next
();
}
}
},
(
req
,
res
,
next
)
=>
{
},
(
req
,
res
,
next
)
=>
{
for
(
let
property
of
required_fields
){
if
(
!
req
.
body
.
name
)
{
// if(!Object.prototype.hasOwnProperty.call(req.body, property)){
res
.
json
({
success
:
false
,
msg
:
'
O campo Nome é obrigatório.
'
});
// res.json({success: false, msg: 'Please fill out all mandatory fields.'});
}
else
{
// return;
next
();
// }
}
},
(
req
,
res
,
next
)
=>
{
if
(
!
req
.
body
.
cpf
)
{
res
.
json
({
success
:
false
,
msg
:
'
O campo CPF é obrigatório.
'
});
}
else
{
next
();
}
},
(
req
,
res
,
next
)
=>
{
if
(
!
req
.
body
.
schooling
)
{
res
.
json
({
success
:
false
,
msg
:
'
O campo Escolaridade é obrigatório.
'
});
}
else
{
next
();
}
},
(
req
,
res
,
next
)
=>
{
if
(
!
req
.
body
.
segment
)
{
res
.
json
({
success
:
false
,
msg
:
'
O campo Segmento é obrigatório.
'
});
}
else
{
next
();
}
},
(
req
,
res
,
next
)
=>
{
if
(
!
req
.
body
.
role
)
{
res
.
json
({
success
:
false
,
msg
:
'
O campo Função é obrigatório.
'
});
}
else
{
next
();
}
},
(
req
,
res
,
next
)
=>
{
if
(
!
req
.
body
.
institution_name
)
{
res
.
json
({
success
:
false
,
msg
:
'
O campo Intituição em que trabalha é obrigatório.
'
});
}
else
{
next
();
}
}
next
();
},
(
req
,
res
,
next
)
=>
{
if
(
!
req
.
body
.
city
)
{
res
.
json
({
success
:
false
,
msg
:
'
O campo Cidade é obrigatório.
'
});
}
else
{
next
();
}
},
(
req
,
res
,
next
)
=>
{
if
(
!
req
.
body
.
state
)
{
res
.
json
({
success
:
false
,
msg
:
'
O campo Estado é obrigatório.
'
});
}
else
{
next
();
}
},
(
req
,
res
,
next
)
=>
{
},
(
req
,
res
,
next
)
=>
{
var
newUser
=
new
User
({
var
newUser
=
new
User
({
email
:
req
.
body
.
email
,
email
:
req
.
body
.
email
,
...
@@ -68,9 +116,10 @@ userApp.post('/', (req, res, next) => {
...
@@ -68,9 +116,10 @@ userApp.post('/', (req, res, next) => {
// save the user
// save the user
newUser
.
save
((
err
)
=>
{
newUser
.
save
((
err
)
=>
{
if
(
err
)
{
if
(
err
)
{
res
.
json
({
success
:
false
,
msg
:
'
Email already in use.
'
});
//no momento retorna essa mensagem se o email OU CPF já estiver cadastrado
res
.
json
({
success
:
false
,
msg
:
'
O email informado já está cadastrado.
'
});
}
else
{
}
else
{
res
.
json
({
success
:
true
,
msg
:
'
Successful created new user.
'
});
res
.
json
({
success
:
true
,
msg
:
'
Usuário cadastrado com sucesso!
'
});
}
}
});
});
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment