admin stuff
This commit is contained in:
@@ -333,4 +333,46 @@ router.get('/me', authenticateToken, async (req, res, next) => {
|
||||
}
|
||||
});
|
||||
|
||||
// @route GET /api/auth/registration-status
|
||||
// @desc Get registration status (public endpoint)
|
||||
// @access Public
|
||||
router.get('/registration-status', async (req, res, next) => {
|
||||
try {
|
||||
// Create admin_settings table if it doesn't exist
|
||||
await pool.query(`
|
||||
CREATE TABLE IF NOT EXISTS admin_settings (
|
||||
id SERIAL PRIMARY KEY,
|
||||
setting_key VARCHAR(255) UNIQUE NOT NULL,
|
||||
setting_value TEXT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
)
|
||||
`);
|
||||
|
||||
// Insert default registration setting if it doesn't exist
|
||||
await pool.query(`
|
||||
INSERT INTO admin_settings (setting_key, setting_value)
|
||||
VALUES ('registrationEnabled', 'true')
|
||||
ON CONFLICT (setting_key) DO NOTHING
|
||||
`);
|
||||
|
||||
// Get registration setting
|
||||
const settingResult = await pool.query(
|
||||
'SELECT setting_value FROM admin_settings WHERE setting_key = $1',
|
||||
['registrationEnabled']
|
||||
);
|
||||
|
||||
const enabled = settingResult.rows.length > 0 ? settingResult.rows[0].setting_value === 'true' : true;
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
data: {
|
||||
enabled
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user