feat: language selector on user creation, pass to welcome email
Some checks failed
Deploy / deploy (push) Failing after 9s
Some checks failed
Deploy / deploy (push) Failing after 9s
Adds preferred_language field to Users, language picker (EN/AR) in create/edit user form, persists to NocoDB, and passes it to the welcome notification so new users receive emails in their language. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -947,7 +947,7 @@ app.get('/api/users/team', requireAuth, async (req, res) => {
|
||||
});
|
||||
|
||||
app.post('/api/users/team', requireAuth, requireRole('superadmin', 'manager'), async (req, res) => {
|
||||
const { name, email, password, team_role, brands, phone, role, role_id, avatar } = req.body;
|
||||
const { name, email, password, team_role, brands, phone, role, role_id, avatar, preferred_language } = req.body;
|
||||
if (!name) return res.status(400).json({ error: 'Name is required' });
|
||||
if (!email) return res.status(400).json({ error: 'Email is required' });
|
||||
|
||||
@@ -972,11 +972,12 @@ app.post('/api/users/team', requireAuth, requireRole('superadmin', 'manager'), a
|
||||
password_hash: passwordHash,
|
||||
role_id: role_id || null,
|
||||
avatar: avatar || null,
|
||||
preferred_language: preferred_language || 'en',
|
||||
});
|
||||
|
||||
const user = await nocodb.get('Users', created.Id);
|
||||
res.status(201).json(stripSensitiveFields({ ...user, id: user.Id, _id: user.Id }));
|
||||
notify.notifyUserInvited({ email, name, password: defaultPassword, inviterName: req.session.userName });
|
||||
notify.notifyUserInvited({ email, name, password: defaultPassword, inviterName: req.session.userName, lang: preferred_language || 'en' });
|
||||
} catch (err) {
|
||||
console.error('Create team member error:', err);
|
||||
res.status(500).json({ error: 'Failed to create team member' });
|
||||
@@ -989,7 +990,7 @@ app.patch('/api/users/team/:id', requireAuth, requireRole('superadmin', 'manager
|
||||
if (!existing) return res.status(404).json({ error: 'User not found' });
|
||||
|
||||
const data = {};
|
||||
for (const f of ['name', 'email', 'team_role', 'phone', 'avatar']) {
|
||||
for (const f of ['name', 'email', 'team_role', 'phone', 'avatar', 'preferred_language']) {
|
||||
if (req.body[f] !== undefined) data[f] = req.body[f];
|
||||
}
|
||||
if (req.body.brands !== undefined) data.brands = JSON.stringify(req.body.brands);
|
||||
|
||||
Reference in New Issue
Block a user