Skip to content

Commit

Permalink
Merge pull request #16 from noremacsim/1.1.0/bug/Fix_Vulnraility_errors
Browse files Browse the repository at this point in the history
Issue: 14 - Fix xss
  • Loading branch information
noremacsim authored Nov 29, 2022
2 parents 08adffa + 57f17a1 commit f471f49
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 10 additions & 2 deletions App/middleware/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
Group,
TwoFactorAuthentication,
} = require(path.join(__dirname, '../../Core/models/'));
const {CustomRoutes} = require("../../Core");

dotenv.config();

Expand Down Expand Up @@ -36,19 +37,26 @@ async function middle(request, h) {
include: User,
});

let requestedPath = '/';
const checkRequestedPath = obj => obj.path === request?.route?.path;

if (CustomRoutes.some(checkRequestedPath)) {
requestedPath = request?.route?.path;
}

if (!authToken) {
h.unstate('jwt');
h.unstate('isLoggedIn');
h.unstate('twoFAPassed');
return h.redirect(`/user/login?path=${request?.route?.path}`);
return h.redirect(`/user/login?path=${requestedPath}`);
}

if (authToken.User.TwoFAEnabled && !authToken.TwoFactorPassed) {
h.state('twoFAPassed', false);
h.state('isLoggedIn', true);
request.user = {};
request.user.id = authToken.User.id;
return h.redirect(`/user/login?path=${request?.route?.path}`);
return h.redirect(`/user/login?path=${requestedPath}`);
}

const user = await User.findOne({
Expand Down
4 changes: 0 additions & 4 deletions Core/driftyCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ const init = async (type) => {
const corsHeaders = process.env.CORS_HEADERS.split(',');
const corsAdditionalHeaders = process.env.CORS_ADDITIONALHEADERS.split(',');

const corsOrigin = process.env.CORS_ORIGIN.split(',');
const corsHeaders = process.env.CORS_HEADERS.split(',');
const corsAdditionalHeaders = process.env.CORS_ADDITIONALHEADERS.split(',');

// Server Options
let options = {
port: PORT,
Expand Down

0 comments on commit f471f49

Please sign in to comment.