Updates to sending user details
This commit is contained in:
@@ -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();
|
||||
Reference in New Issue
Block a user