Merge pull request #428 from PiR1/fix/update-event-access
Fix/update event access
This commit is contained in:
@@ -25,6 +25,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **event:** fix updating client access ([ee85e1d](https://github.com/the-luap/picpeak/commit/ee85e1d))
|
||||
|
||||
### Features
|
||||
|
||||
* **i18n:** add French (fr) language support with full translation coverage
|
||||
|
||||
@@ -1192,14 +1192,6 @@ router.put('/:id', adminAuth, requirePermission('events.edit'), requireEventOwne
|
||||
return res.status(400).json({ error: 'external_path is required when source_mode is reference' });
|
||||
}
|
||||
|
||||
// Handle client access fields (#172)
|
||||
if (Object.prototype.hasOwnProperty.call(updates, 'client_access_enabled')) {
|
||||
updates.client_access_enabled = formatBoolean(updates.client_access_enabled);
|
||||
// Auto-generate client share token when first enabling
|
||||
if (parseBooleanInput(updates.client_access_enabled, false) && !event.client_share_token) {
|
||||
updates.client_share_token = crypto.randomBytes(32).toString('hex');
|
||||
}
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(updates, 'client_password') && updates.client_password) {
|
||||
updates.client_password_hash = await bcrypt.hash(updates.client_password, getBcryptRounds());
|
||||
delete updates.client_password;
|
||||
@@ -1281,6 +1273,15 @@ router.put('/:id', adminAuth, requirePermission('events.edit'), requireEventOwne
|
||||
}
|
||||
}
|
||||
|
||||
// Handle client access fields (#172)
|
||||
if (Object.prototype.hasOwnProperty.call(updates, 'client_access_enabled')) {
|
||||
updates.client_access_enabled = formatBoolean(updates.client_access_enabled);
|
||||
// Auto-generate client share token when first enabling
|
||||
if (parseBooleanInput(updates.client_access_enabled, false) && !event.client_share_token && !updates.client_share_token) {
|
||||
updates.client_share_token = crypto.randomBytes(32).toString('hex');
|
||||
}
|
||||
}
|
||||
|
||||
// Update event
|
||||
await db('events')
|
||||
.where('id', id)
|
||||
|
||||
Reference in New Issue
Block a user