Add password reset localization and chat configuration
- Implemented German and English localization for password reset functionality. - Added WebSocket URL resolution logic in chat services to support various environments and configurations. - Created centralized chat configuration for event keys and payload mappings. - Developed RoomsView component for admin chat room management, including create, edit, and delete functionalities.
This commit is contained in:
@@ -177,9 +177,60 @@ class AdminController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
async updateRoom(req, res) {
|
||||
try {
|
||||
const userId = req.headers.userid;
|
||||
if (!userId || !(await AdminService.hasUserAccess(userId, 'chatrooms'))) {
|
||||
return res.status(403).json({ error: 'Keine Berechtigung.' });
|
||||
}
|
||||
const schema = Joi.object({
|
||||
title: Joi.string().min(1).max(255).required(),
|
||||
roomTypeId: Joi.number().integer().required(),
|
||||
isPublic: Joi.boolean().required(),
|
||||
genderRestrictionId: Joi.number().integer().allow(null),
|
||||
minAge: Joi.number().integer().min(0).allow(null),
|
||||
maxAge: Joi.number().integer().min(0).allow(null),
|
||||
password: Joi.string().allow('', null),
|
||||
friendsOfOwnerOnly: Joi.boolean().allow(null),
|
||||
requiredUserRightId: Joi.number().integer().allow(null)
|
||||
});
|
||||
const { error, value } = schema.validate(req.body);
|
||||
if (error) {
|
||||
return res.status(400).json({ error: error.details[0].message });
|
||||
}
|
||||
const room = await AdminService.updateRoom(req.params.id, value);
|
||||
res.status(200).json(room);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async createRoom(req, res) {
|
||||
try {
|
||||
const room = await AdminService.createRoom(req.body);
|
||||
const userId = req.headers.userid;
|
||||
if (!userId || !(await AdminService.hasUserAccess(userId, 'chatrooms'))) {
|
||||
return res.status(403).json({ error: 'Keine Berechtigung.' });
|
||||
}
|
||||
const schema = Joi.object({
|
||||
title: Joi.string().min(1).max(255).required(),
|
||||
roomTypeId: Joi.number().integer().required(),
|
||||
isPublic: Joi.boolean().required(),
|
||||
genderRestrictionId: Joi.number().integer().allow(null),
|
||||
minAge: Joi.number().integer().min(0).allow(null),
|
||||
maxAge: Joi.number().integer().min(0).allow(null),
|
||||
password: Joi.string().allow('', null),
|
||||
friendsOfOwnerOnly: Joi.boolean().allow(null),
|
||||
requiredUserRightId: Joi.number().integer().allow(null)
|
||||
});
|
||||
const { error, value } = schema.validate(req.body);
|
||||
if (error) {
|
||||
return res.status(400).json({ error: error.details[0].message });
|
||||
}
|
||||
const room = await AdminService.createRoom(value);
|
||||
res.status(201).json(room);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
@@ -189,6 +240,10 @@ class AdminController {
|
||||
|
||||
async deleteRoom(req, res) {
|
||||
try {
|
||||
const userId = req.headers.userid;
|
||||
if (!userId || !(await AdminService.hasUserAccess(userId, 'chatrooms'))) {
|
||||
return res.status(403).json({ error: 'Keine Berechtigung.' });
|
||||
}
|
||||
await AdminService.deleteRoom(req.params.id);
|
||||
res.sendStatus(204);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user