Updates to sending user details

This commit is contained in:
2025-08-03 13:26:20 -06:00
parent 6b4732db65
commit 86685a13a6
22 changed files with 1669 additions and 156 deletions

View File

@@ -2,6 +2,7 @@ const nocodbService = require('../services/nocodb');
const logger = require('../utils/logger');
const config = require('../config');
const { sanitizeUser, extractId } = require('../utils/helpers');
const { sendLoginDetails } = require('../services/email');
class UsersController {
async getAll(req, res) {
@@ -155,6 +156,47 @@ class UsersController {
});
}
}
async sendLoginDetails(req, res) {
try {
const userId = req.params.id;
if (!config.nocodb.loginSheetId) {
return res.status(500).json({
success: false,
error: 'Login sheet not configured'
});
}
// Get user data from database
const user = await nocodbService.getById(
config.nocodb.loginSheetId,
userId
);
if (!user) {
return res.status(404).json({
success: false,
error: 'User not found'
});
}
// Send login details email
await sendLoginDetails(user);
res.json({
success: true,
message: 'Login details sent successfully'
});
} catch (error) {
logger.error('Error sending login details:', error);
res.status(500).json({
success: false,
error: 'Failed to send login details'
});
}
}
}
module.exports = new UsersController();