mirror of
https://github.com/status-im/codimd.git
synced 2025-01-28 03:05:01 +00:00
b94c13059e
Signed-off-by: Raccoon <raccoon@hackmd.io>
29 lines
869 B
TypeScript
29 lines
869 B
TypeScript
import {Router} from "express";
|
|
import passport from "passport";
|
|
import {Strategy as TwitterStrategy} from "passport-twitter";
|
|
|
|
import * as config from "../../config";
|
|
import {passportGeneralCallback, setReturnToFromReferer} from "../utils";
|
|
|
|
const twitterAuth = Router()
|
|
export = module.exports
|
|
|
|
passport.use(new TwitterStrategy({
|
|
consumerKey: config.twitter.consumerKey,
|
|
consumerSecret: config.twitter.consumerSecret,
|
|
callbackURL: config.serverURL + '/auth/twitter/callback'
|
|
}, passportGeneralCallback))
|
|
|
|
twitterAuth.get('/auth/twitter', function (req, res, next) {
|
|
setReturnToFromReferer(req)
|
|
passport.authenticate('twitter')(req, res, next)
|
|
})
|
|
|
|
// twitter auth callback
|
|
twitterAuth.get('/auth/twitter/callback',
|
|
passport.authenticate('twitter', {
|
|
successReturnToOrRedirect: config.serverURL + '/',
|
|
failureRedirect: config.serverURL + '/'
|
|
})
|
|
)
|