1
0
mirror of https://github.com/microsoft/TypeScript-Node-Starter.git synced 2025-11-08 20:27:37 +00:00

Replace passport-local definition file with @types/passport-local

This commit:
- use @types/passport-local
- removes custom definition file
- updates implementation to use correct interface from @types/passport-local

Thanks!
This commit is contained in:
Peter Blazejewicz
2018-01-05 22:30:54 +01:00
parent 351b1ce677
commit c1c23a0b99
3 changed files with 3 additions and 50 deletions

View File

@@ -4,7 +4,7 @@ import * as nodemailer from "nodemailer";
import * as passport from "passport";
import { default as User, UserModel, AuthToken } from "../models/User";
import { Request, Response, NextFunction } from "express";
import { LocalStrategyInfo } from "passport-local";
import { IVerifyOptions } from "passport-local";
import { WriteError } from "mongodb";
const request = require("express-validator");
@@ -38,7 +38,7 @@ export let postLogin = (req: Request, res: Response, next: NextFunction) => {
return res.redirect("/login");
}
passport.authenticate("local", (err: Error, user: UserModel, info: LocalStrategyInfo) => {
passport.authenticate("local", (err: Error, user: UserModel, info: IVerifyOptions) => {
if (err) { return next(err); }
if (!user) {
req.flash("errors", info.message);

View File

@@ -1,48 +0,0 @@
// Type definitions for passport-local 1.0.0
// Project: https://github.com/jaredhanson/passport-local
// Definitions by: Maxime LUCE <https://github.com/SomaticIT>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="passport"/>
import passport = require("passport");
import express = require("express");
interface IStrategyOptions {
usernameField?: string;
passwordField?: string;
passReqToCallback?: boolean;
}
interface IStrategyOptionsWithRequest {
usernameField?: string;
passwordField?: string;
passReqToCallback: boolean;
}
interface IVerifyOptions {
message: string;
}
interface VerifyFunctionWithRequest {
(req: express.Request, username: string, password: string, done: (error: any, user?: any, options?: IVerifyOptions) => void): void;
}
interface VerifyFunction {
(username: string, password: string, done: (error: any, user?: any, options?: IVerifyOptions) => void): void;
}
declare class Strategy implements passport.Strategy {
constructor(options: IStrategyOptionsWithRequest, verify: VerifyFunctionWithRequest);
constructor(options: IStrategyOptions, verify: VerifyFunction);
constructor(verify: VerifyFunction);
name: string;
authenticate: (req: express.Request, options?: Object) => void;
}
interface LocalStrategyInfo {
message: string;
}