mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
bugfix & rename test file
This commit is contained in:
@@ -34,7 +34,7 @@ app.post('/login',
|
||||
});
|
||||
|
||||
app.post('/login', function(req, res, next) {
|
||||
passport.authenticate('local', function(err, user, info) {
|
||||
passport.authenticate('local', function(err: any, user: { username: string; }, info: { message: string; }) {
|
||||
if (err) { return next(err) }
|
||||
if (!user) {
|
||||
req.session.error = info.message;
|
||||
@@ -52,6 +52,33 @@ app.get('/logout', function(req, res) {
|
||||
res.redirect('/');
|
||||
});
|
||||
|
||||
function authSetting(): void {
|
||||
var authOption = {
|
||||
successRedirect: '/',
|
||||
failureRedirect: '/login',
|
||||
};
|
||||
var successCallback = (req: express.Request, res: express.Response) => {
|
||||
res.redirect('/');
|
||||
};
|
||||
|
||||
app.get('/auth/facebook',
|
||||
passport.authenticate('facebook'));
|
||||
app.get('/auth/facebook/callback',
|
||||
passport.authenticate('facebook', authOption), successCallback);
|
||||
|
||||
app.get('/auth/twitter',
|
||||
passport.authenticate('twitter'));
|
||||
app.get('/auth/twitter/callback',
|
||||
passport.authenticate('twitter', authOption));
|
||||
|
||||
app.get('/auth/google',
|
||||
passport.authenticate('google', { scope:
|
||||
[ 'https://www.googleapis.com/auth/userinfo.profile' ] }));
|
||||
app.get('/auth/google/callback',
|
||||
passport.authenticate('google', authOption), successCallback);
|
||||
|
||||
}
|
||||
|
||||
function ensureAuthenticated(req: express.Request, res: express.Response, next: (err?: any) => void) {
|
||||
if (req.isAuthenticated()) { return next(); }
|
||||
if (req.isUnauthenticated()) {
|
||||
Vendored
+2
-2
@@ -15,8 +15,8 @@ declare module 'passport' {
|
||||
function initialize(options?: { userProperty: string; }): express.Handler;
|
||||
function session(options?: { pauseStream: boolean; }): express.Handler;
|
||||
|
||||
function authenticate(strategy: string, options: Object, callback?: express.Handler): express.Handler;
|
||||
function authenticate(strategy: string, callback2: (err: any, user: any, info: any) => void): express.Handler;
|
||||
function authenticate(strategy: string, callback?: Function): express.Handler;
|
||||
function authenticate(strategy: string, options: Object, callback?: Function): express.Handler;
|
||||
function authorize(strategy: string, options: Object, callback?: express.Handler): express.Handler;
|
||||
function serializeUser(fn: (user: any, done: (err: any, id: any) => void) => void): void;
|
||||
function deserializeUser(fn: (id: any, done: (err: any, user: any) => void) => void): void;
|
||||
|
||||
Reference in New Issue
Block a user