You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
798 B
29 lines
798 B
import { Strategy } from 'passport-google-oauth20'
|
|
|
|
import { Router } from 'express'
|
|
import passport from 'passport'
|
|
|
|
import genericStrategy from '../strategy'
|
|
|
|
const strategyOptions = {
|
|
clientID: process.env.GOOGLE_CLIENT_ID,
|
|
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
|
|
callbackURL: `${process.env.HOST}/auth/google/redirect` ?? '/auth/google/redirect',
|
|
}
|
|
|
|
export function googleStrategy() {
|
|
return new Strategy(strategyOptions, genericStrategy('google'))
|
|
}
|
|
|
|
export const googleRouter = Router()
|
|
|
|
const googleAuthenticateOptions = {
|
|
scope: ['email', 'profile'],
|
|
}
|
|
|
|
googleRouter.get('/google', passport.authenticate('google', googleAuthenticateOptions))
|
|
googleRouter.get(
|
|
'/google/redirect',
|
|
passport.authenticate('google', { successRedirect: '/museo', failureRedirect: '/' }),
|
|
)
|