Stricter handle cleanup
This commit is contained in:
parent
4f3780979e
commit
accebd00f5
|
@ -16,9 +16,11 @@
|
||||||
<span data-i18n="This action is irreversible.">This action is irreversible.</span>
|
<span data-i18n="This action is irreversible.">This action is irreversible.</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label for="deleteUserHandle" data-i18n="Type the user's handle below to confirm:">
|
<label for="deleteUserHandle">
|
||||||
Type the user's handle below to confirm:
|
<strong data-i18n="Type the user's handle below to confirm:">
|
||||||
|
Type the user's handle below to confirm:
|
||||||
|
</strong>
|
||||||
</label>
|
</label>
|
||||||
<input id="deleteUserHandle" name="deleteUserHandle" type="text" class="text_pole" placeholder="">
|
<input id="deleteUserHandle" name="deleteUserHandle" type="text" class="text_pole" placeholder="[ Type here ]">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -50,7 +50,7 @@ const DEFAULT_USER = Object.freeze({
|
||||||
uuid: '00000000-0000-0000-0000-000000000000',
|
uuid: '00000000-0000-0000-0000-000000000000',
|
||||||
handle: 'user0',
|
handle: 'user0',
|
||||||
name: 'User',
|
name: 'User',
|
||||||
created: 0,
|
created: Date.now(),
|
||||||
password: '',
|
password: '',
|
||||||
admin: true,
|
admin: true,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
|
|
@ -157,7 +157,12 @@ router.post('/create', requireAdminMiddleware, jsonParser, async (request, respo
|
||||||
}
|
}
|
||||||
|
|
||||||
const handles = await getAllUserHandles();
|
const handles = await getAllUserHandles();
|
||||||
const handle = slugify(request.body.handle, { lower: true, trim: true });
|
const handle = slugify(request.body.handle, { lower: true, trim: true, remove: /[^a-z0-9-]/g });
|
||||||
|
|
||||||
|
if (!handle) {
|
||||||
|
console.log('Create user failed: Invalid handle');
|
||||||
|
return response.status(400).json({ error: 'Invalid handle' });
|
||||||
|
}
|
||||||
|
|
||||||
if (handles.some(x => x === handle)) {
|
if (handles.some(x => x === handle)) {
|
||||||
console.log('Create user failed: User with that handle already exists');
|
console.log('Create user failed: User with that handle already exists');
|
||||||
|
|
Loading…
Reference in New Issue