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
4c83aac5
There was a problem fetching the pipeline summary.
Commit
4c83aac5
authored
8 years ago
by
Lucas Gabriel Lima
Browse files
Options
Downloads
Patches
Plain Diff
add passport config
parent
ce56e687
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!20
Auth
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libs/middlewares/passport.js
+26
-0
26 additions, 0 deletions
src/libs/middlewares/passport.js
with
26 additions
and
0 deletions
src/libs/middlewares/passport.js
0 → 100644
+
26
−
0
View file @
4c83aac5
const
JwtStrategy
=
require
(
'
passport-jwt
'
).
Strategy
;
const
libs
=
`
${
process
.
cwd
()}
/libs`
;
const
config
=
require
(
`
${
libs
}
/config`
);
const
User
=
(
'
../models/user
'
);
module
.
exports
=
function
(
passport
){
var
opts
=
{};
opts
.
secretOrKey
=
config
.
get
(
'
mongodb:secret
'
);
passport
.
use
(
new
JwtStrategy
(
opts
,
function
(
jwt_payload
,
done
){
User
.
find
({
id
:
jwt_payload
.
id
},
function
(
err
,
user
){
if
(
err
)
{
return
done
(
err
);
}
if
(
!
user
)
{
return
done
(
null
,
false
,
{
message
:
'
Unknown user
'
});
}
if
(
!
user
.
comparePassword
(
password
))
{
return
done
(
null
,
false
,
{
message
:
'
Invalid password
'
});
}
return
done
(
null
,
user
);
});
}));
};
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