From 1903ba12af1731dca8e6ca0a8df5e691f9a8c733 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Mon, 13 Apr 2020 13:18:31 +0200 Subject: [PATCH] auth/index.ts: Refactor Gitlab & Dropbox middlewares Signed-off-by: David Mehren --- lib/web/auth/dropbox/index.ts | 9 ++++----- lib/web/auth/index.ts | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/web/auth/dropbox/index.ts b/lib/web/auth/dropbox/index.ts index 30dff424d..0ed3c7324 100644 --- a/lib/web/auth/dropbox/index.ts +++ b/lib/web/auth/dropbox/index.ts @@ -1,13 +1,13 @@ +import { NextFunction, Request, Response, Router } from 'express' import passport from 'passport' -import { config } from '../../../config' -import { passportGeneralCallback } from '../utils' -import { Router, Response, NextFunction, Request } from 'express' import * as DropboxStrategy from 'passport-dropbox-oauth2' +import { config } from '../../../config' import { AuthMiddleware } from '../interface' +import { passportGeneralCallback } from '../utils' export const dropboxAuth = Router() -export const EmailMiddleware: AuthMiddleware = { +export const DropboxMiddleware: AuthMiddleware = { getMiddleware (): Router { passport.use(new DropboxStrategy({ apiVersion: '2', @@ -27,5 +27,4 @@ export const EmailMiddleware: AuthMiddleware = { ) return dropboxAuth } - } diff --git a/lib/web/auth/index.ts b/lib/web/auth/index.ts index bb4bf000e..98dafb44a 100644 --- a/lib/web/auth/index.ts +++ b/lib/web/auth/index.ts @@ -6,8 +6,8 @@ import { User } from '../../models' import { FacebookMiddleware } from './facebook' import { TwitterMiddleware } from './twitter' import { GithubMiddleware } from './github' -import gitlab from './gitlab' -import dropbox from './dropbox' +import { GitlabMiddleware } from './gitlab' +import { DropboxMiddleware } from './dropbox' import google from './google' import ldap from './ldap' import saml from './saml' @@ -46,8 +46,8 @@ passport.deserializeUser(function (id: string, done) { if (config.isFacebookEnable) AuthRouter.use(FacebookMiddleware.getMiddleware()) if (config.isTwitterEnable) AuthRouter.use(TwitterMiddleware.getMiddleware()) if (config.isGitHubEnable) AuthRouter.use(GithubMiddleware.getMiddleware()) -if (config.isGitLabEnable) AuthRouter.use(gitlab) -if (config.isDropboxEnable) AuthRouter.use(dropbox) +if (config.isGitLabEnable) AuthRouter.use(GitlabMiddleware.getMiddleware()) +if (config.isDropboxEnable) AuthRouter.use(DropboxMiddleware.getMiddleware()) if (config.isGoogleEnable) AuthRouter.use(google) if (config.isLDAPEnable) AuthRouter.use(ldap) if (config.isSAMLEnable) AuthRouter.use(saml)