mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge pull request #31432 from kstiehl/master
[passport] - consitent typing of options passed to authorize & authenticate
This commit is contained in:
Vendored
+4
-3
@@ -1,10 +1,11 @@
|
||||
// Type definitions for Passport 0.4
|
||||
// Type definitions for Passport 1.0
|
||||
// Project: http://passportjs.org
|
||||
// Definitions by: Horiuchi_H <https://github.com/horiuchi>
|
||||
// Eric Naeseth <https://github.com/enaeseth>
|
||||
// Igor Belagorudsky <https://github.com/theigor>
|
||||
// Tomek Łaziuk <https://github.com/tlaziuk>
|
||||
// Daniel Perez Alvarez <https://github.com/danielpa9708>
|
||||
// Kevin Stiehl <https://github.com/kstiehl>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -52,7 +53,7 @@ declare namespace passport {
|
||||
prompt?: string;
|
||||
}
|
||||
|
||||
interface Authenticator<InitializeRet = express.Handler, AuthenticateRet = any, AuthorizeRet = AuthenticateRet> {
|
||||
interface Authenticator<InitializeRet = express.Handler, AuthenticateRet = any, AuthorizeRet = AuthenticateRet, AuthorizeOptions = AuthenticateOptions> {
|
||||
use(strategy: Strategy): this;
|
||||
use(name: string, strategy: Strategy): this;
|
||||
unuse(name: string): this;
|
||||
@@ -63,7 +64,7 @@ declare namespace passport {
|
||||
authenticate(strategy: string | string[], callback?: (...args: any[]) => any): AuthenticateRet;
|
||||
authenticate(strategy: string | string[], options: AuthenticateOptions, callback?: (...args: any[]) => any): AuthenticateRet;
|
||||
authorize(strategy: string | string[], callback?: (...args: any[]) => any): AuthorizeRet;
|
||||
authorize(strategy: string | string[], options: any, callback?: (...args: any[]) => any): AuthorizeRet;
|
||||
authorize(strategy: string | string[], options: AuthorizeOptions, callback?: (...args: any[]) => any): AuthorizeRet;
|
||||
serializeUser<TUser, TID>(fn: (user: TUser, done: (err: any, id?: TID) => void) => void): void;
|
||||
deserializeUser<TUser, TID>(fn: (id: TID, done: (err: any, user?: TUser) => void) => void): void;
|
||||
transformAuthInfo(fn: (info: any, done: (err: any, info: any) => void) => void): void;
|
||||
|
||||
@@ -78,6 +78,12 @@ app.post('/login',
|
||||
res.redirect('/');
|
||||
});
|
||||
|
||||
app.post('/login',
|
||||
passport.authorize('local', { failureRedirect: '/login', failureFlash: true }),
|
||||
(req, res) => {
|
||||
res.redirect('/');
|
||||
});
|
||||
|
||||
app.post('/login', (req, res, next) => {
|
||||
passport.authenticate('local', (err: any, user: { username: string; }, info: { message: string; }) => {
|
||||
if (err) { return next(err); }
|
||||
|
||||
Reference in New Issue
Block a user