mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #13481 from horiuchi/passport-update
[passport] fix lint error
This commit is contained in:
Vendored
+58
-65
@@ -1,10 +1,8 @@
|
||||
// Type definitions for Passport v0.2.0
|
||||
// Type definitions for Passport 0.3
|
||||
// Project: http://passportjs.org
|
||||
// Definitions by: Horiuchi_H <https://github.com/horiuchi/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="express" />
|
||||
|
||||
declare namespace Express {
|
||||
export interface Request {
|
||||
authInfo?: any;
|
||||
@@ -12,9 +10,9 @@ declare namespace Express {
|
||||
|
||||
// These declarations are merged into express's Request type
|
||||
login(user: any, done: (err: any) => void): void;
|
||||
login(user: any, options: Object, done: (err: any) => void): void;
|
||||
login(user: any, options: any, done: (err: any) => void): void;
|
||||
logIn(user: any, done: (err: any) => void): void;
|
||||
logIn(user: any, options: Object, done: (err: any) => void): void;
|
||||
logIn(user: any, options: any, done: (err: any) => void): void;
|
||||
|
||||
logout(): void;
|
||||
logOut(): void;
|
||||
@@ -29,77 +27,72 @@ declare module 'passport' {
|
||||
|
||||
namespace passport {
|
||||
|
||||
interface AuthenticateOptions {
|
||||
authInfo?:boolean;
|
||||
assignProperty?:string;
|
||||
failureFlash?: string|boolean|Object;
|
||||
failureMessage?: boolean|string;
|
||||
failureRedirect?:string;
|
||||
failWithError?:boolean;
|
||||
session?: boolean;
|
||||
scope?: string|string[];
|
||||
successFlash?: string|boolean|Object;
|
||||
successMessage?: boolean|string;
|
||||
successRedirect?:string;
|
||||
successReturnToOrRedirect?:string;
|
||||
pauseStream?:boolean;
|
||||
userProperty?:string;
|
||||
}
|
||||
interface AuthenticateOptions {
|
||||
authInfo?: boolean;
|
||||
assignProperty?: string;
|
||||
failureFlash?: string|boolean|any;
|
||||
failureMessage?: boolean|string;
|
||||
failureRedirect?: string;
|
||||
failWithError?: boolean;
|
||||
session?: boolean;
|
||||
scope?: string|string[];
|
||||
successFlash?: string|boolean|any;
|
||||
successMessage?: boolean|string;
|
||||
successRedirect?: string;
|
||||
successReturnToOrRedirect?: string;
|
||||
pauseStream?: boolean;
|
||||
userProperty?: string;
|
||||
}
|
||||
|
||||
interface Passport {
|
||||
use(strategy: passport.Strategy): Passport;
|
||||
use(name: string, strategy: passport.Strategy): Passport;
|
||||
unuse(name: string): Passport;
|
||||
framework(fw: passport.Framework): Passport;
|
||||
initialize(options?: { userProperty: string; }): express.Handler;
|
||||
session(options?: { pauseStream: boolean; }): express.Handler;
|
||||
interface Passport {
|
||||
use(strategy: passport.Strategy): this;
|
||||
use(name: string, strategy: passport.Strategy): this;
|
||||
unuse(name: string): this;
|
||||
framework(fw: passport.Framework): this;
|
||||
initialize(options?: { userProperty: string; }): express.Handler;
|
||||
session(options?: { pauseStream: boolean; }): express.Handler;
|
||||
|
||||
authenticate(strategy: string, callback?: Function): express.Handler;
|
||||
authenticate(strategy: string, options: AuthenticateOptions, callback?: Function): express.Handler;
|
||||
authenticate(strategies: string[], callback?: Function): express.Handler;
|
||||
authenticate(strategies: string[], options: AuthenticateOptions, callback?: Function): express.Handler;
|
||||
authorize(strategy: string, callback?: Function): express.Handler;
|
||||
authorize(strategy: string, options: Object, callback?: Function): express.Handler;
|
||||
authorize(strategies: string[], callback?: Function): express.Handler;
|
||||
authorize(strategies: string[], options: Object, callback?: Function): express.Handler;
|
||||
serializeUser(fn: (user: any, done: (err: any, id: any) => void) => void): void;
|
||||
serializeUser<TUser, TID>(fn: (user: TUser, done: (err: any, id: TID) => void) => void): void;
|
||||
deserializeUser(fn: (id: any, done: (err: any, user: any) => 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;
|
||||
}
|
||||
authenticate(strategy: string|string[], callback?: Function): express.Handler;
|
||||
authenticate(strategy: string|string[], options: AuthenticateOptions, callback?: Function): express.Handler;
|
||||
authorize(strategy: string|string[], callback?: Function): express.Handler;
|
||||
authorize(strategy: string|string[], options: any, callback?: Function): express.Handler;
|
||||
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;
|
||||
}
|
||||
|
||||
interface Strategy {
|
||||
name?: string;
|
||||
authenticate(req: express.Request, options?: Object): void;
|
||||
}
|
||||
interface Strategy {
|
||||
name?: string;
|
||||
authenticate(req: express.Request, options?: any): void;
|
||||
}
|
||||
|
||||
interface Profile {
|
||||
provider: string;
|
||||
id: string;
|
||||
displayName: string;
|
||||
interface Profile {
|
||||
provider: string;
|
||||
id: string;
|
||||
displayName: string;
|
||||
username?: string;
|
||||
name?: {
|
||||
familyName: string;
|
||||
givenName: string;
|
||||
middleName?: string;
|
||||
};
|
||||
emails?: {
|
||||
value: string;
|
||||
type?: string;
|
||||
}[];
|
||||
photos?: {
|
||||
value: string;
|
||||
}[];
|
||||
}
|
||||
familyName: string;
|
||||
givenName: string;
|
||||
middleName?: string;
|
||||
};
|
||||
emails?: Array<{
|
||||
value: string;
|
||||
type?: string;
|
||||
}>;
|
||||
photos?: Array<{
|
||||
value: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
interface Framework {
|
||||
initialize(passport: Passport, options?: Object): Function;
|
||||
authenticate(passport: Passport, name: string, options?: Object, callback?: Function): Function;
|
||||
authorize?(passport: Passport, name: string, options?: Object, callback?: Function): Function;
|
||||
initialize(passport: Passport, options?: any): Function;
|
||||
authenticate(passport: Passport, name: string, options?: any, callback?: Function): Function;
|
||||
authorize?(passport: Passport, name: string, options?: any, callback?: Function): Function;
|
||||
}
|
||||
}
|
||||
|
||||
const passport: passport.Passport;
|
||||
export = passport;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import * as express from 'express';
|
||||
import 'express-session';
|
||||
import * as passport from 'passport';
|
||||
|
||||
|
||||
/// <reference types="express-session" />
|
||||
|
||||
import express = require('express');
|
||||
import passport = require('passport');
|
||||
|
||||
class TestStrategy implements passport.Strategy {
|
||||
public name: string = 'test';
|
||||
constructor() { }
|
||||
@@ -45,7 +43,7 @@ app.configure(() => {
|
||||
app.use(passport.session());
|
||||
});
|
||||
|
||||
app.post('/login',
|
||||
app.post('/login',
|
||||
passport.authenticate('local', { failureRedirect: '/login', failureFlash: true }),
|
||||
function (req, res) {
|
||||
res.redirect('/');
|
||||
@@ -55,7 +53,9 @@ app.post('/login', function (req, res, next) {
|
||||
passport.authenticate('local', function (err: any, user: { username: string; }, info: { message: string; }) {
|
||||
if (err) { return next(err) }
|
||||
if (!user) {
|
||||
req.session['error'] = info.message;
|
||||
if (req.session) {
|
||||
req.session['error'] = info.message;
|
||||
}
|
||||
return res.redirect('/login')
|
||||
}
|
||||
req.logIn(user, function (err) {
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": false,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -16,4 +17,4 @@
|
||||
"index.d.ts",
|
||||
"passport-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user