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
255948d9
Commit
255948d9
authored
Oct 06, 2020
by
Dumindu Sanjana Hettiarachchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
3e6ef318
Pipeline
#1703
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
routes/auth.js
routes/auth.js
+31
-0
No files found.
routes/auth.js
0 → 100644
View file @
255948d9
const
{
Router
}
=
require
(
'
express
'
)
const
passport
=
require
(
'
passport
'
)
// init router for auth
let
router
=
Router
()
router
.
get
(
'
/login
'
,
function
(
req
,
res
)
{
if
(
req
.
user
)
res
.
redirect
(
'
/dashboard
'
)
// if auth
else
res
.
redirect
(
'
/auth/login/google
'
)
// if not auth
})
// login redirect
router
.
get
(
'
/login/google
'
,
passport
.
authenticate
(
"
google
"
,
{
scope
:
[
'
profile
'
,
"
https://www.googleapis.com/auth/drive.file
"
,
"
email
"
]
}))
// callback from google oauth (with token)
router
.
get
(
'
/google/redirect
'
,
passport
.
authenticate
(
'
google
'
),
function
(
req
,
res
)
{
res
.
redirect
(
'
/dashboard
'
)
})
// logout
router
.
get
(
'
/logout
'
,
function
(
req
,
res
)
{
req
.
logOut
();
res
.
redirect
(
'
/
'
)
})
module
.
exports
=
router
\ 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