mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-16 00:11:30 +00:00
Merge 464b720d9e into 47ea6b5092
This commit is contained in:
commit
3de0dedfd9
11 changed files with 236 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ const Logger = require('../Logger')
|
|||
/**
|
||||
* @typedef {Object} ApiKeyPermissions
|
||||
* @property {boolean} download
|
||||
* @property {boolean} stream
|
||||
* @property {boolean} update
|
||||
* @property {boolean} delete
|
||||
* @property {boolean} upload
|
||||
|
|
@ -84,6 +85,7 @@ class ApiKey extends Model {
|
|||
static getDefaultPermissions() {
|
||||
return {
|
||||
download: true,
|
||||
stream: true,
|
||||
update: true,
|
||||
delete: true,
|
||||
upload: true,
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ class User extends Model {
|
|||
*/
|
||||
static permissionMapping = {
|
||||
canDownload: 'download',
|
||||
canStream: 'stream',
|
||||
canUpload: 'upload',
|
||||
canDelete: 'delete',
|
||||
canUpdate: 'update',
|
||||
|
|
@ -169,6 +170,7 @@ class User extends Model {
|
|||
static getDefaultPermissionsForUserType(type) {
|
||||
return {
|
||||
download: true,
|
||||
stream: true,
|
||||
update: type === 'root' || type === 'admin',
|
||||
delete: type === 'root',
|
||||
upload: type === 'root' || type === 'admin',
|
||||
|
|
@ -567,6 +569,9 @@ class User extends Model {
|
|||
get canDownload() {
|
||||
return !!this.permissions?.download && this.isActive
|
||||
}
|
||||
get canStream() {
|
||||
return (this.permissions?.stream !== false) && this.isActive
|
||||
}
|
||||
get canUpload() {
|
||||
return !!this.permissions?.upload && this.isActive
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue