feat: make social login optional

This commit is contained in:
Lin, Hung-Shin committed 2023-10-05 13:32:02 +08:00
1 parent a79b66ed8d
commit 72b2711367
5 files changed
+145 -49

No files matched your search

+15 -8
View File
@@ -1,6 +1,8 @@
import { Router } from 'express'
import passport from 'passport'
import enabledMethods from '../../auth/passport.js'
import {
register,
checkUsername,
@@ -26,14 +28,19 @@ router.get('/check-username', checkUsername)
router.get('/check-session', checkSession)
router.get('/google', passport.authenticate('google'))
router.get('/available-methods', (req, res) => {
res.json(enabledMethods)
})
router.get(
'/google/callback',
passport.authenticate('google', {
successRedirect: '/',
failureRedirect: '/login',
})
)
if (enabledMethods.google) {
router.get('/google', passport.authenticate('google'))
router.get(
'/google/callback',
passport.authenticate('google', {
successRedirect: '/',
failureRedirect: '/login',
})
)
}
export default router