From e85a6a9c3932b0c37f9b2678734b4b142370cd10 Mon Sep 17 00:00:00 2001 From: Antony Budianto Date: Sun, 19 Nov 2017 10:33:08 +0700 Subject: [PATCH] gitignore lib --- .gitignore | 1 + lib/auth.middleware.js | 25 ------------------------- lib/index.js | 7 ------- lib/util/logger.js | 15 --------------- 4 files changed, 1 insertion(+), 47 deletions(-) delete mode 100644 lib/auth.middleware.js delete mode 100644 lib/index.js delete mode 100644 lib/util/logger.js diff --git a/.gitignore b/.gitignore index 76efb07..040abad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules +lib .vscode diff --git a/lib/auth.middleware.js b/lib/auth.middleware.js deleted file mode 100644 index 2dfdb67..0000000 --- a/lib/auth.middleware.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -var admin = require.main.require('firebase-admin'); - -var logger = require('./util/logger'); - -function firebaseAuthMiddleware(req, res, next) { - var authorization = req.header('Authorization'); - if (authorization) { - var token = authorization.split(' '); - admin.auth().verifyIdToken(token[1]).then(function (decodedToken) { - logger.log(decodedToken); - res.locals.user = decodedToken; - next(); - }).catch(function (err) { - logger.log(err); - res.sendStatus(401); - }); - } else { - logger.log('Authorization header is not found'); - res.sendStatus(401); - } -} - -module.exports = firebaseAuthMiddleware; \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e7d5966..0000000 --- a/lib/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var auth = require('./auth.middleware'); - -module.exports = { - auth: auth -}; \ No newline at end of file diff --git a/lib/util/logger.js b/lib/util/logger.js deleted file mode 100644 index 0e3e792..0000000 --- a/lib/util/logger.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var debug = process.env.APP_DEBUG === 'true'; - -function log() { - var _console; - - if (!debug) return; - - (_console = console).log.apply(_console, arguments); -} - -module.exports = { - log: log -}; \ No newline at end of file