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
Harbor Registry
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
6a345d17
Commit
6a345d17
authored
1 year ago
by
ems19
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] Create and Update problems
parent
5dcdc130
No related branches found
No related tags found
4 merge requests
!377
prd_version of simcaq
,
!373
merge dev -> homologa
,
!370
Dev migration
,
!369
Postgres migration
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/libs/models/publication.js
+7
-0
7 additions, 0 deletions
src/libs/models/publication.js
src/libs/models/user.js
+16
-4
16 additions, 4 deletions
src/libs/models/user.js
src/libs/routes_v1/user.js
+8
-2
8 additions, 2 deletions
src/libs/routes_v1/user.js
with
31 additions
and
6 deletions
src/libs/models/publication.js
+
7
−
0
View file @
6a345d17
...
...
@@ -14,6 +14,10 @@ var Publication = db.define("Publication",{
allowNull
:
false
,
validate
:
{
notNull
:
{
msg
:
"
O campo categoria é obrigatória e aceita apenas os valores 'Artigo', 'Tese', 'Dissertação', 'Relatório', 'Periódico.
"
},
isIn
:{
args
:
[[
"
Artigo
"
,
"
Tese
"
,
"
Dissertação
"
,
"
Relatório
"
,
"
Periódico
"
]],
msg
:
"
O campo categoria é obrigatória e aceita apenas os valores 'Artigo', 'Tese', 'Dissertação', 'Relatório', 'Periódico'.
"
}
}
},
title
:{
...
...
@@ -37,6 +41,9 @@ var Publication = db.define("Publication",{
allowNull
:
false
,
validate
:
{
notNull
:
{
msg
:
"
O campo origem é obrigatória e aceita apenas os valores 'Baixar', 'Acessar'.
"
},
isIn
:{
args
:
[[
"
Baixar
"
,
"
Acessar
"
]],
msg
:
"
O campo origem é obrigatória e aceita apenas os valores 'Baixar', 'Acessar'.
"
}
}
},
link
:{
...
...
This diff is collapsed.
Click to expand it.
src/libs/models/user.js
+
16
−
4
View file @
6a345d17
...
...
@@ -18,6 +18,7 @@ var User = db.define("User",{
unique
:
true
,
validate
:
{
notNull
:
{
msg
:
"
O campo Email é obrigatório.
"
},
notEmpty
:
{
msg
:
"
O campo Email é obrigatório.
"
}
}
},
password
:{
...
...
@@ -36,6 +37,7 @@ var User = db.define("User",{
allowNull
:
false
,
validate
:
{
notNull
:
{
msg
:
"
O campo Nome é obrigatório.
"
},
notEmpty
:
{
msg
:
"
O campo Nome é obrigatório.
"
}
}
},
nickname
:{
...
...
@@ -43,6 +45,7 @@ var User = db.define("User",{
allowNull
:
false
,
validate
:
{
notNull
:
{
msg
:
"
O campo Apelido é obrigatório.
"
},
notEmpty
:
{
msg
:
"
O campo Apelido é obrigatório.
"
}
}
},
cpf
:{
...
...
@@ -51,6 +54,7 @@ var User = db.define("User",{
unique
:
true
,
validate
:
{
notNull
:
{
msg
:
"
O campo CPF é obrigatório.
"
},
notEmpty
:
{
msg
:
"
O campo CPF é obrigatório.
"
}
}
},
cep
:{
...
...
@@ -58,6 +62,7 @@ var User = db.define("User",{
allowNull
:
false
,
validate
:
{
notNull
:
{
msg
:
"
O campo CEP é obrigatório.
"
},
notEmpty
:
{
msg
:
"
O campo CEP é obrigatório.
"
}
}
},
schooling
:{
...
...
@@ -65,6 +70,7 @@ var User = db.define("User",{
allowNull
:
false
,
validate
:
{
notNull
:
{
msg
:
"
O campo Formação é obrigatório.
"
},
notEmpty
:
{
msg
:
"
O campo Formação é obrigatório.
"
}
}
},
course
:{
...
...
@@ -84,6 +90,7 @@ var User = db.define("User",{
allowNull
:
false
,
validate
:
{
notNull
:
{
msg
:
"
O campo Segmento é obrigatório.
"
},
notEmpty
:
{
msg
:
"
O campo Segmento é obrigatório.
"
}
}
},
role
:{
...
...
@@ -91,6 +98,7 @@ var User = db.define("User",{
allowNull
:
false
,
validate
:
{
notNull
:
{
msg
:
"
O campo Função é obrigatório.
"
},
notEmpty
:
{
msg
:
"
O campo Função é obrigatório.
"
}
}
},
institution_name
:{
...
...
@@ -98,6 +106,7 @@ var User = db.define("User",{
allowNull
:
false
,
validate
:
{
notNull
:
{
msg
:
"
O campo Instituição em que trabalha ou estuda é obrigatório.
"
},
notEmpty
:
{
msg
:
"
O campo Instituição em que trabalha ou estuda é obrigatório.
"
}
}
},
state
:{
...
...
@@ -105,6 +114,7 @@ var User = db.define("User",{
allowNull
:
false
,
validate
:
{
notNull
:
{
msg
:
"
O campo Estado é obrigatório.
"
},
notEmpty
:
{
msg
:
"
O campo Estado é obrigatório.
"
}
}
},
city
:{
...
...
@@ -112,6 +122,7 @@ var User = db.define("User",{
allowNull
:
false
,
validate
:
{
notNull
:
{
msg
:
"
O campo Cidade é obrigatório.
"
},
notEmpty
:
{
msg
:
"
O campo Cidade é obrigatório.
"
}
}
},
receive_email
:{
...
...
@@ -126,6 +137,7 @@ var User = db.define("User",{
allowNull
:
false
,
validate
:
{
notNull
:
{
msg
:
"
O campo origem é obrigatória e aceita apenas os valores 'LDE', 'SimCAQ' e 'MAPFOR'.
"
},
notEmpty
:
{
msg
:
"
O campo origem é obrigatória e aceita apenas os valores 'LDE', 'SimCAQ' e 'MAPFOR'.
"
}
}
},
verified
:{
...
...
@@ -169,10 +181,10 @@ User.generateObjectId = function(){
}
const
setSaltAndPassword
=
user
=>
{
//
if (user.changed('password')) {
user
.
salt
=
User
.
generateSalt
()
user
.
hashed_password
=
User
.
encryptPassword
(
user
.
password
,
user
.
salt
).
toString
(
'
hex
'
);
//
}
if
(
user
.
changed
(
'
password
'
))
{
user
.
salt
=
User
.
generateSalt
()
user
.
hashed_password
=
User
.
encryptPassword
(
user
.
password
,
user
.
salt
).
toString
(
'
hex
'
);
}
}
const
setObjectId
=
user
=>
{
...
...
This diff is collapsed.
Click to expand it.
src/libs/routes_v1/user.js
+
8
−
2
View file @
6a345d17
...
...
@@ -108,6 +108,10 @@ userApp.get('/me', passport.authenticate('bearer', { session: false }), (req, re
next
();
},
response
(
'
user
'
));
function
isEmpty
(
str
)
{
return
(
!
str
||
str
.
length
===
0
);
}
userApp
.
get
(
'
/:id
'
,
(
req
,
res
,
next
)
=>
{
User
.
findByPk
(
req
.
params
.
id
).
then
((
user
)
=>
{
if
(
!
user
)
{
...
...
@@ -136,7 +140,8 @@ userApp.post('/', async (req, res, next) => {
if
(
typeof
req
.
body
.
password
===
'
undefined
'
||
!
req
.
body
.
password
)
{
res
.
statusCode
=
400
;
return
res
.
json
({
errors
:
[
"
O campo senha é obrigatório
"
]
});
}
else
{
}
else
{
let
user
=
await
User
.
create
({
id
:
0
,
email
:
req
.
body
.
email
,
...
...
@@ -240,7 +245,8 @@ userApp.put('/:id', passport.authenticate('bearer', { session: false }), async (
user
.
citesegment
=
req
.
body
.
citesegment
||
user
.
citesegment
;
user
.
citerole
=
req
.
body
.
citerole
||
user
.
citerole
;
if
((
req
.
body
.
password
!=
""
)
&&
(
req
.
body
.
newpassword
!=
""
))
{
if
((
!
isEmpty
(
req
.
body
.
password
))
&&
(
!
isEmpty
(
req
.
body
.
newpassword
))){
console
.
log
(
"
ENTREI INFELIZMENTE
"
)
if
(
req
.
body
.
password
!=
req
.
body
.
newpassword
)
{
if
(
user
.
checkPassword
(
user
,
req
.
body
.
password
))
{
await
user
.
update
({
password
:
req
.
body
.
newpassword
});
...
...
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