From 018514e53f3d079780f5a9e559e75820af756975 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Tue, 3 Dec 2019 20:14:21 -0500 Subject: fixed routing --- src/server/authentication/config/passport.ts | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'src/server/authentication/config') diff --git a/src/server/authentication/config/passport.ts b/src/server/authentication/config/passport.ts index 0ced99b0d..286209b20 100644 --- a/src/server/authentication/config/passport.ts +++ b/src/server/authentication/config/passport.ts @@ -1,8 +1,6 @@ import * as passport from 'passport'; import * as passportLocal from 'passport-local'; -import _ from "lodash"; import { default as User } from '../models/user_model'; -import { Request, Response, NextFunction } from "express"; const LocalStrategy = passportLocal.Strategy; @@ -28,21 +26,4 @@ passport.use(new LocalStrategy({ usernameField: 'email', passReqToCallback: true return done(undefined, user); }); }); -})); - -export let isAuthenticated = (req: Request, res: Response, next: NextFunction) => { - if (req.isAuthenticated()) { - return next(); - } - return res.redirect("/login"); -}; - -export let isAuthorized = (req: Request, res: Response, next: NextFunction) => { - const provider = req.path.split("/").slice(-1)[0]; - - if (_.find(req.user && "tokens" in req.user ? req.user["tokens"] : undefined, { kind: provider })) { - next(); - } else { - res.redirect(`/auth/${provider}`); - } -}; \ No newline at end of file +})); \ No newline at end of file -- cgit v1.2.3-70-g09d2