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
aee72b35
There was a problem fetching the pipeline summary.
Commit
aee72b35
authored
8 years ago
by
Lucas Gabriel Lima
Browse files
Options
Downloads
Patches
Plain Diff
update API responses to match use cases's
parent
daab538b
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
+12
-5
12 additions, 5 deletions
src/libs/routes/user.js
with
12 additions
and
5 deletions
src/libs/routes/user.js
+
12
−
5
View file @
aee72b35
...
@@ -150,8 +150,15 @@ userApp.post('/', (req, res, next) => {
...
@@ -150,8 +150,15 @@ userApp.post('/', (req, res, next) => {
});
});
userApp
.
post
(
'
/authenticate
'
,
(
req
,
res
,
next
)
=>
{
userApp
.
post
(
'
/authenticate
'
,
(
req
,
res
,
next
)
=>
{
if
(
!
req
.
body
.
email
||
!
req
.
body
.
password
)
{
if
(
!
req
.
body
.
email
)
{
res
.
json
({
success
:
false
,
msg
:
'
Please pass email and password.
'
});
res
.
json
({
success
:
false
,
msg
:
'
O campo Email é obrigatório.
'
});
}
else
{
next
();
}
},
(
req
,
res
,
next
)
=>
{
if
(
!
req
.
body
.
password
)
{
res
.
json
({
success
:
false
,
msg
:
'
O campo Senha é obrigatório.
'
});
}
else
{
}
else
{
next
();
next
();
}
}
...
@@ -163,7 +170,7 @@ userApp.post('/authenticate', (req, res, next) => {
...
@@ -163,7 +170,7 @@ userApp.post('/authenticate', (req, res, next) => {
if
(
err
)
throw
err
;
if
(
err
)
throw
err
;
if
(
!
user
){
if
(
!
user
){
res
.
json
({
success
:
false
,
msg
:
'
Authentication failed. User not found
.
'
});
res
.
json
({
success
:
false
,
msg
:
'
O Email informado não está cadastrado
.
'
});
}
}
else
{
else
{
user
.
comparePassword
(
req
.
body
.
password
,
(
err
,
isMatch
)
=>
{
user
.
comparePassword
(
req
.
body
.
password
,
(
err
,
isMatch
)
=>
{
...
@@ -174,10 +181,10 @@ userApp.post('/authenticate', (req, res, next) => {
...
@@ -174,10 +181,10 @@ userApp.post('/authenticate', (req, res, next) => {
var
token
=
jwt
.
encode
(
user
,
secret
);
var
token
=
jwt
.
encode
(
user
,
secret
);
//returns user info including token as json
//returns user info including token as json
res
.
json
({
success
:
true
,
token
:
'
JWT
'
+
token
});
res
.
json
({
success
:
true
,
token
:
'
JWT
'
+
token
,
msg
:
'
Usuário autenticado com sucesso
'
});
}
}
else
{
else
{
res
.
json
({
success
:
false
,
msg
:
'
A
uthentication failed. Wrong password
'
});
res
.
json
({
success
:
false
,
msg
:
'
A
Senha informada é inválida.
'
});
}
}
});
});
}
}
...
...
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