Skip to content

Commit

Permalink
Merge pull request #22 from VidulHB/patch-4
Browse files Browse the repository at this point in the history
Auto Enable
  • Loading branch information
PasinduDushan authored Oct 31, 2022
2 parents 97f6f71 + 64323c1 commit fb81676
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const isAuthenticated = (req, res, next) => {
};

const isEnabled = async (req, res, next) => {
try {
const data = await IMP.findOne({ power_admin: 1 });
if(!data){
let newData = new IMP({
Expand All @@ -50,9 +51,14 @@ const isEnabled = async (req, res, next) => {
} else {
next();
}
}
catch (e) {
console.error('Error');
next();
}
};

router.get("/", async (req, res, next) => {
router.get("/", isEnabled, async (req, res, next) => {
const data = await Analytics.findOne({ analytics_id: 1043 });
if(!data){
let newData = new Analytics({
Expand Down

0 comments on commit fb81676

Please sign in to comment.