Merge pull request #11871 from AtlasDev/types-2.0

Updated typings passport-beam
This commit is contained in:
Arthur Ozga
2016-10-11 11:39:32 -07:00
committed by GitHub
2 changed files with 9 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
// Type definitions for passport-beam 1.0.4
// Project: https://github.com/alfw/passport-beam
// Definitions by: AtlasDev <https://github.com/AtlasDev>
// Definitions by: AtlasDev <https://github.com/AtlasDev>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference types="passport"/>
@@ -9,13 +9,13 @@
import * as passport from 'passport';
import * as express from 'express';
declare class Strategy implements passport.Strategy {
export class Strategy implements passport.Strategy {
constructor(options: Strategy.IStrategyOption, verify: (accessToken: string, refreshToken: string, profile: Strategy.Profile, done: (error: any, user?: any) => void) => void);
name: string;
authenticate: (req: express.Request, options?: Object) => void;
}
declare namespace Strategy {
export namespace Strategy {
interface IStrategyOption {
clientID: string;
clientSecret: string;
@@ -28,9 +28,7 @@ declare namespace Strategy {
username: string;
provider: string;
email: string;
_raw: string;
_raw: any;
_json: any;
}
}
export = Strategy;
}

View File

@@ -3,8 +3,8 @@
/**
* Created by AtlasDev on 4/10/2016.
*/
import passport = require('passport');
import Beam = require('passport-beam');
import * as passport from 'passport';
import { Strategy } from 'passport-beam';
var User = {
findOrCreate(id:string, provider:string, callback:(err:Error, user:any) => void): void {
@@ -12,11 +12,11 @@ var User = {
}
}
passport.use(new Beam({
passport.use(new Strategy({
clientID: process.env.BEAM_CLIENT_ID,
clientSecret: process.env.BEAM_CLIENT_SECRET,
callbackURL: "http://127.0.0.1:3000/auth/beam/callback"
}, (accessToken:string, refreshToken:string, profile:Beam.Profile, done:(error:any, user?:any) => void) => {
}, (accessToken:string, refreshToken:string, profile:Strategy.Profile, done:(error:any, user?:any) => void) => {
User.findOrCreate(profile.id, profile.provider, (err, user) => {
if (err) { return done(err); }
done(null, user);