Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
Oauth2_ssd
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dumindu Sanjana Hettiarachchi
Oauth2_ssd
Commits
3b3d4c4d
Commit
3b3d4c4d
authored
Oct 06, 2020
by
Dumindu Sanjana Hettiarachchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
7c9c46b9
Pipeline
#1695
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
configs/passport.js
configs/passport.js
+51
-0
No files found.
configs/passport.js
0 → 100644
View file @
3b3d4c4d
const
passport
=
require
(
'
passport
'
)
const
GoogleStrategy
=
require
(
'
passport-google-oauth20
'
)
const
KEYS
=
require
(
'
./keys
'
)
// set cookie base on this user
passport
.
serializeUser
((
user
,
done
)
=>
{
let
sessionUser
=
{
_id
:
user
.
googleID
,
accessToken
:
user
.
accesstoken
,
name
:
user
.
name
,
pic_url
:
user
.
pic_url
,
email
:
user
.
email
}
done
(
null
,
sessionUser
)
})
// get cookie & get relevent session data
passport
.
deserializeUser
((
sessionUser
,
done
)
=>
{
done
(
null
,
sessionUser
)
// now can access request.user
})
passport
.
use
(
// google login
new
GoogleStrategy
(
// google keys
{
clientID
:
KEYS
.
googleOauth
.
clientID
,
clientSecret
:
KEYS
.
googleOauth
.
clientSecret
,
callbackURL
:
KEYS
.
googleOauth
.
callback
,
passReqToCallback
:
true
},
(
request
,
accessToken
,
refreshToken
,
profile
,
done
)
=>
{
//save data in session
user
=
{
"
accesstoken
"
:
accessToken
,
'
googleID
'
:
profile
.
id
,
'
name
'
:
profile
.
displayName
,
'
pic_url
'
:
profile
.
_json
.
picture
,
'
email
'
:
profile
.
_json
.
email
}
done
(
null
,
user
)
}
)
)
\ No newline at end of file
Write
Preview
Markdown
is supported
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