Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/JWT_Infrastructure' into JWT_Inf…
Browse files Browse the repository at this point in the history
…rastructure
  • Loading branch information
evscott committed Feb 8, 2019
2 parents f3029c9 ae161ba commit b1c70c1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 27 deletions.
16 changes: 0 additions & 16 deletions server/Configs.js

This file was deleted.

10 changes: 5 additions & 5 deletions server/handlers/authHandler.js
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
require('dotenv').config();
const jwt = require('jsonwebtoken');
const Configs = require('../Config');
const Config = require('../Config');
const databaseHandler = require('./databaseHandler');

// Query database handler with signup request.
Expand All @@ -14,8 14,8 @@ let signup = async (req, res) => {
// Retrieve json web token
let token = jwt.sign(
{ username: username, password: password },
Configs.privateKey,
Configs.signOptions
Config.privateKey,
Config.signOptions
);

// Signup success.
Expand Down Expand Up @@ -56,8 56,8 @@ let login = async (req, res) => {
// Retrieve json web token
let token = jwt.sign(
{ username: username, password: password },
Configs.privateKey,
Configs.signOptions
Config.privateKey,
Config.signOptions
);

// Login success.
Expand Down
6 changes: 3 additions & 3 deletions server/handlers/middleware.js
Original file line number Diff line number Diff line change
@@ -1,5 1,5 @@
const jwt = require('jsonwebtoken');
const Configs = require('../Config');
const Config = require('../Config');

let checkToken = (req, res, next) => {
// Express headers are auto converted to lowercase
Expand All @@ -11,8 11,8 @@ let checkToken = (req, res, next) => {
// Determine if jwt token is legit
let legit = jwt.verify(
token,
Configs.publicKey,
Configs.verifyOptions,
Config.publicKey,
Config.verifyOptions,
(err, decoded) => {
if (err) {
return res.json({
Expand Down
6 changes: 3 additions & 3 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 4,7 @@ const app = express();
const path = require('path');
const bodyParser = require('body-parser');
const authRoutes = require('./controller/authroutes');
const Configs = require('./Config');
const Config = require('./Config');
const port = process.env.PORT || 4201;

app.use(
Expand All @@ -18,6 18,6 @@ app.route('/*', (req, res) => {
app.use(express.static(path.join(__dirname, '/../dist')));
app.use(express.json()); //
app.use(bodyParser.json());
app.use(Configs.AccessControl);
app.use(Config.AccessControl);
app.use('/', authRoutes);
app.listen(port, () => console.log(`Listening on port: ${port}...`));
app.listen(port, () => console.log(`Listening on port: ${port}...`));

0 comments on commit b1c70c1

Please sign in to comment.