21 lines
628 B
JavaScript
21 lines
628 B
JavaScript
const verifyBetaPassword = (req, res, next) => {
|
|
const betaPassword = req.headers['x-beta-password'];
|
|
const configuredPassword = process.env.BETA_PASSWORD;
|
|
|
|
if (!configuredPassword) {
|
|
console.error('BETA_PASSWORD environment variable is not set');
|
|
return res.status(500).json({ error: 'Beta password not configured on server' });
|
|
}
|
|
|
|
if (!betaPassword) {
|
|
return res.status(401).json({ error: 'Beta password required' });
|
|
}
|
|
|
|
if (betaPassword !== configuredPassword) {
|
|
return res.status(403).json({ error: 'Invalid beta password' });
|
|
}
|
|
|
|
next();
|
|
};
|
|
|
|
module.exports = { verifyBetaPassword }; |