mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-09-01 13:51:27 +02:00
User create ereader endpoint validate accessibility
This commit is contained in:
parent
1fb17ef1fe
commit
702c082e66
@ -38,10 +38,6 @@ export default {
|
|||||||
ereaderDevice: {
|
ereaderDevice: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => null
|
default: () => null
|
||||||
},
|
|
||||||
users: {
|
|
||||||
type: Array,
|
|
||||||
default: () => []
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@ -78,29 +74,6 @@ export default {
|
|||||||
},
|
},
|
||||||
title() {
|
title() {
|
||||||
return !this.ereaderDevice ? 'Create Device' : 'Update Device'
|
return !this.ereaderDevice ? 'Create Device' : 'Update Device'
|
||||||
},
|
|
||||||
userAvailabilityOptions() {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
text: this.$strings.LabelAdminUsersOnly,
|
|
||||||
value: 'adminOrUp'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: this.$strings.LabelAllUsersExcludingGuests,
|
|
||||||
value: 'userOrUp'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: this.$strings.LabelAllUsersIncludingGuests,
|
|
||||||
value: 'guestOrUp'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: this.$strings.LabelSelectUsers,
|
|
||||||
value: 'specificUsers'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
userOptions() {
|
|
||||||
return this.users.map((u) => ({ text: u.username, value: u.id }))
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -409,12 +409,15 @@ class MeController {
|
|||||||
for (const device of userEReaderDevices) {
|
for (const device of userEReaderDevices) {
|
||||||
if (!device.name || !device.email) {
|
if (!device.name || !device.email) {
|
||||||
return res.status(400).send('Invalid payload. ereaderDevices array items must have name and email')
|
return res.status(400).send('Invalid payload. ereaderDevices array items must have name and email')
|
||||||
|
} else if (device.availabilityOption !== 'specificUsers' || device.users?.length !== 1 || device.users[0] !== req.user.id) {
|
||||||
|
return res.status(400).send('Invalid payload. ereaderDevices array items must have availabilityOption "specificUsers" and only the current user')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const otherDevices = Database.emailSettings.ereaderDevices.filter((device) => {
|
const otherDevices = Database.emailSettings.ereaderDevices.filter((device) => {
|
||||||
return !Database.emailSettings.checkUserCanAccessDevice(device, req.user) || device.users?.length !== 1
|
return !Database.emailSettings.checkUserCanAccessDevice(device, req.user) || device.users?.length !== 1
|
||||||
})
|
})
|
||||||
|
|
||||||
const ereaderDevices = otherDevices.concat(userEReaderDevices)
|
const ereaderDevices = otherDevices.concat(userEReaderDevices)
|
||||||
|
|
||||||
// Check for duplicate names
|
// Check for duplicate names
|
||||||
|
Loading…
Reference in New Issue
Block a user