added in the user managment section. Need to also do some updates to the admin menue and whatnot however itll get figured.

This commit is contained in:
2025-07-17 17:48:50 -06:00
parent 88b80bc750
commit 6aae0fee41
22 changed files with 1382 additions and 226 deletions

View File

@@ -6,19 +6,34 @@ const { sanitizeUser, extractId } = require('../utils/helpers');
class UsersController {
async getAll(req, res) {
try {
// Debug logging
logger.info('UsersController.getAll called');
logger.info('loginSheetId from config:', config.nocodb.loginSheetId);
logger.info('NocoDB config:', {
apiUrl: config.nocodb.apiUrl,
hasToken: !!config.nocodb.apiToken,
projectId: config.nocodb.projectId,
tableId: config.nocodb.tableId,
loginSheetId: config.nocodb.loginSheetId
});
if (!config.nocodb.loginSheetId) {
logger.error('Login sheet not configured in environment');
return res.status(500).json({
success: false,
error: 'Login sheet not configured'
error: 'Login sheet not configured. Please set NOCODB_LOGIN_SHEET in your environment variables.'
});
}
logger.info('Fetching users from NocoDB...');
// Remove the sort parameter that's causing the error
const response = await nocodbService.getAll(config.nocodb.loginSheetId, {
limit: 100,
sort: '-created_at'
limit: 100
// Removed: sort: '-created_at'
});
const users = response.list || [];
logger.info(`Retrieved ${users.length} users from database`);
// Remove password field from response for security
const safeUsers = users.map(sanitizeUser);
@@ -32,7 +47,7 @@ class UsersController {
logger.error('Error fetching users:', error);
res.status(500).json({
success: false,
error: 'Failed to fetch users'
error: 'Failed to fetch users: ' + error.message
});
}
}
@@ -65,7 +80,7 @@ class UsersController {
});
}
// Create new user
// Create new user - use the actual column names from your table
const userData = {
Email: email,
email: email,
@@ -74,9 +89,8 @@ class UsersController {
Name: name || '',
name: name || '',
Admin: admin === true,
admin: admin === true,
'Created At': new Date().toISOString(),
created_at: new Date().toISOString()
admin: admin === true
// Removed created_at fields as they might not exist
};
const response = await nocodbService.create(