mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-15 13:51:35 +00:00
proxy auth users don't get a token
otherwise, they will stay logged in even after the proxy auth has disabled them (with the saved token in the local store)
This commit is contained in:
parent
a85ae7467c
commit
20356a17d8
2 changed files with 23 additions and 10 deletions
|
|
@ -63,7 +63,7 @@ class Auth {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token == null && proxyUsername == null) {
|
if (token == null && proxyUsername == null) {
|
||||||
Logger.error('Api called without a token and proxy auth is disabled', req.path)
|
Logger.error('Api called without a token and no proxy auth provided', req.path)
|
||||||
return res.sendStatus(401)
|
return res.sendStatus(401)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,6 +158,8 @@ class Auth {
|
||||||
email,
|
email,
|
||||||
type: 'user',
|
type: 'user',
|
||||||
isActive: true,
|
isActive: true,
|
||||||
|
token: null,
|
||||||
|
isFromProxy: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
return await this.createUser(account)
|
return await this.createUser(account)
|
||||||
|
|
@ -178,7 +180,11 @@ class Auth {
|
||||||
|
|
||||||
account.pash = await this.hashPass(password)
|
account.pash = await this.hashPass(password)
|
||||||
|
|
||||||
|
// proxy users don't get a token
|
||||||
|
if (!account.isFromProxy) {
|
||||||
account.token = await this.generateAccessToken({ userId: account.id, username })
|
account.token = await this.generateAccessToken({ userId: account.id, username })
|
||||||
|
}
|
||||||
|
|
||||||
account.createdAt = Date.now()
|
account.createdAt = Date.now()
|
||||||
const newUser = new User(account)
|
const newUser = new User(account)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ class User {
|
||||||
this.librariesAccessible = [] // Library IDs (Empty if ALL libraries)
|
this.librariesAccessible = [] // Library IDs (Empty if ALL libraries)
|
||||||
this.itemTagsSelected = [] // Empty if ALL item tags accessible
|
this.itemTagsSelected = [] // Empty if ALL item tags accessible
|
||||||
|
|
||||||
|
this.isFromProxy = false // whether the user was authenticated in the proxy layer
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
this.construct(user)
|
this.construct(user)
|
||||||
}
|
}
|
||||||
|
|
@ -90,7 +92,8 @@ class User {
|
||||||
createdAt: this.createdAt,
|
createdAt: this.createdAt,
|
||||||
permissions: this.permissions,
|
permissions: this.permissions,
|
||||||
librariesAccessible: [...this.librariesAccessible],
|
librariesAccessible: [...this.librariesAccessible],
|
||||||
itemTagsSelected: [...this.itemTagsSelected]
|
itemTagsSelected: [...this.itemTagsSelected],
|
||||||
|
isFromProxy: this.isFromProxy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,7 +114,8 @@ class User {
|
||||||
createdAt: this.createdAt,
|
createdAt: this.createdAt,
|
||||||
permissions: this.permissions,
|
permissions: this.permissions,
|
||||||
librariesAccessible: [...this.librariesAccessible],
|
librariesAccessible: [...this.librariesAccessible],
|
||||||
itemTagsSelected: [...this.itemTagsSelected]
|
itemTagsSelected: [...this.itemTagsSelected],
|
||||||
|
isFromProxy: this.isFromProxy,
|
||||||
}
|
}
|
||||||
if (minimal) {
|
if (minimal) {
|
||||||
delete json.mediaProgress
|
delete json.mediaProgress
|
||||||
|
|
@ -183,6 +187,9 @@ class User {
|
||||||
|
|
||||||
this.librariesAccessible = [...(user.librariesAccessible || [])]
|
this.librariesAccessible = [...(user.librariesAccessible || [])]
|
||||||
this.itemTagsSelected = [...(user.itemTagsSelected || [])]
|
this.itemTagsSelected = [...(user.itemTagsSelected || [])]
|
||||||
|
|
||||||
|
|
||||||
|
this.isFromProxy = false
|
||||||
}
|
}
|
||||||
|
|
||||||
update(payload) {
|
update(payload) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue