added route to check if rooms need authentication

This commit is contained in:
Bruno Roesner 2024-10-19 18:24:28 -04:00
parent f648d028ab
commit 98e3887bcd
3 changed files with 23 additions and 0 deletions

View file

@ -175,6 +175,17 @@ class AuthConfig {
}
}
// Check if students must be authenticated to join a room
getRoomsRequireAuth() {
const roomRequireAuth = process.env.AUTHENTICATED_ROOMS;
if (!roomRequireAuth || roomRequireAuth !== "true") {
return false;
}
return true;
}
}

View file

@ -20,6 +20,17 @@ class authController {
}
}
async getRoomsRequireAuth(req, res, next) {
const authC = new AuthConfig();
const roomsRequireAuth = authC.getRoomsRequireAuth();
const response = {
roomsRequireAuth
}
return res.json(response);
}
}
module.exports = new authController;

View file

@ -5,5 +5,6 @@ const jwt = require('../middleware/jwtToken.js');
const authController = require('../controllers/auth.js')
router.get("/getActiveAuth",authController.getActive);
router.get("/getRoomsRequireAuth", authController.getRoomsRequireAuth);
module.exports = router;