Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SSD Assignment2
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
pumudu seniya fernando
SSD Assignment2
Commits
3959772d
Commit
3959772d
authored
Oct 06, 2020
by
pumudu seniya fernando
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
2e354dfe
Pipeline
#1689
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 @
3959772d
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 from google **
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