Created toggle for enable / disable user signup flow with user role

Fixed numbers mismatching in host cards
Fixed issues with the settings file
Fixed layouts on hosts/packages/repos
Added ability to delete multiple hosts at once
Fixed Dark mode styling in areas
Removed console debugging messages
Done some other stuff ...
This commit is contained in:
Muhammad Ibrahim
2025-09-22 01:01:50 +01:00
parent a268f6b8f1
commit 797be20c45
29 changed files with 940 additions and 4015 deletions

View File

@@ -34,7 +34,7 @@ router.get('/check-admin-users', async (req, res) => {
router.post('/setup-admin', [
body('username').isLength({ min: 1 }).withMessage('Username is required'),
body('email').isEmail().withMessage('Valid email is required'),
body('password').isLength({ min: 6 }).withMessage('Password must be at least 6 characters')
body('password').isLength({ min: 8 }).withMessage('Password must be at least 8 characters for security')
], async (req, res) => {
try {
const errors = validationResult(req);
@@ -425,6 +425,17 @@ router.post('/admin/users/:userId/reset-password', authenticateToken, requireMan
}
});
// Check if signup is enabled (public endpoint)
router.get('/signup-enabled', async (req, res) => {
try {
const settings = await prisma.settings.findFirst();
res.json({ signupEnabled: settings?.signup_enabled || false });
} catch (error) {
console.error('Error checking signup status:', error);
res.status(500).json({ error: 'Failed to check signup status' });
}
});
// Public signup endpoint
router.post('/signup', [
body('username').isLength({ min: 3 }).withMessage('Username must be at least 3 characters'),
@@ -432,6 +443,12 @@ router.post('/signup', [
body('password').isLength({ min: 6 }).withMessage('Password must be at least 6 characters')
], async (req, res) => {
try {
// Check if signup is enabled
const settings = await prisma.settings.findFirst();
if (!settings?.signup_enabled) {
return res.status(403).json({ error: 'User signup is currently disabled' });
}
const errors = validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).json({ errors: errors.array() });