mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-13 10:55:05 +02:00
Log when token expiry is set via env var, api-keys create/update returns with user association
This commit is contained in:
parent
e201247d69
commit
e24eaab3f1
4 changed files with 14 additions and 5 deletions
|
@ -93,7 +93,7 @@ export default {
|
||||||
this.$toast.error(data.error)
|
this.$toast.error(data.error)
|
||||||
} else {
|
} else {
|
||||||
this.removeApiKey(apiKey.id)
|
this.removeApiKey(apiKey.id)
|
||||||
this.$emit('deleted', apiKey.id)
|
this.$emit('numApiKeys', this.apiKeys.length)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
<tables-api-keys-table ref="apiKeysTable" class="pt-2" @edit="setShowApiKeyModal" @numApiKeys="(count) => (numApiKeys = count)" />
|
<tables-api-keys-table ref="apiKeysTable" class="pt-2" @edit="setShowApiKeyModal" @numApiKeys="(count) => (numApiKeys = count)" />
|
||||||
</app-settings-content>
|
</app-settings-content>
|
||||||
<modals-api-key-modal ref="apiKeyModal" v-model="showApiKeyModal" :api-key="selectedApiKey" :users="users" @created="apiKeyCreated" @deleted="apiKeyDeleted" @updated="apiKeyUpdated" />
|
<modals-api-key-modal ref="apiKeyModal" v-model="showApiKeyModal" :api-key="selectedApiKey" :users="users" @created="apiKeyCreated" @updated="apiKeyUpdated" />
|
||||||
<modals-api-key-created-modal ref="apiKeyCreatedModal" v-model="showApiKeyCreatedModal" :api-key="selectedApiKey" />
|
<modals-api-key-created-modal ref="apiKeyCreatedModal" v-model="showApiKeyCreatedModal" :api-key="selectedApiKey" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -50,9 +50,6 @@ export default {
|
||||||
this.$refs.apiKeysTable.addApiKey(apiKey)
|
this.$refs.apiKeysTable.addApiKey(apiKey)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
apiKeyDeleted() {
|
|
||||||
this.numApiKeys--
|
|
||||||
},
|
|
||||||
apiKeyUpdated(apiKey) {
|
apiKeyUpdated(apiKey) {
|
||||||
if (this.$refs.apiKeysTable) {
|
if (this.$refs.apiKeysTable) {
|
||||||
this.$refs.apiKeysTable.updateApiKey(apiKey)
|
this.$refs.apiKeysTable.updateApiKey(apiKey)
|
||||||
|
|
|
@ -25,6 +25,12 @@ class Auth {
|
||||||
|
|
||||||
this.RefreshTokenExpiry = parseInt(process.env.REFRESH_TOKEN_EXPIRY) || 7 * 24 * 60 * 60 // 7 days
|
this.RefreshTokenExpiry = parseInt(process.env.REFRESH_TOKEN_EXPIRY) || 7 * 24 * 60 * 60 // 7 days
|
||||||
this.AccessTokenExpiry = parseInt(process.env.ACCESS_TOKEN_EXPIRY) || 12 * 60 * 60 // 12 hours
|
this.AccessTokenExpiry = parseInt(process.env.ACCESS_TOKEN_EXPIRY) || 12 * 60 * 60 // 12 hours
|
||||||
|
if (parseInt(process.env.REFRESH_TOKEN_EXPIRY) > 0) {
|
||||||
|
Logger.info(`[Auth] Refresh token expiry set from ENV variable to ${this.RefreshTokenExpiry} seconds`)
|
||||||
|
}
|
||||||
|
if (parseInt(process.env.ACCESS_TOKEN_EXPIRY) > 0) {
|
||||||
|
Logger.info(`[Auth] Access token expiry set from ENV variable to ${this.AccessTokenExpiry} seconds`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -87,6 +87,9 @@ class ApiKeyController {
|
||||||
isActive: !!req.body.isActive,
|
isActive: !!req.body.isActive,
|
||||||
createdByUserId: req.user.id
|
createdByUserId: req.user.id
|
||||||
})
|
})
|
||||||
|
apiKeyInstance.dataValues.user = await apiKeyInstance.getUser({
|
||||||
|
attributes: ['id', 'username', 'type']
|
||||||
|
})
|
||||||
|
|
||||||
Logger.info(`[ApiKeyController] Created API key "${apiKeyInstance.name}"`)
|
Logger.info(`[ApiKeyController] Created API key "${apiKeyInstance.name}"`)
|
||||||
return res.json({
|
return res.json({
|
||||||
|
@ -152,6 +155,9 @@ class ApiKeyController {
|
||||||
|
|
||||||
if (hasUpdates) {
|
if (hasUpdates) {
|
||||||
await apiKey.save()
|
await apiKey.save()
|
||||||
|
apiKey.dataValues.user = await apiKey.getUser({
|
||||||
|
attributes: ['id', 'username', 'type']
|
||||||
|
})
|
||||||
Logger.info(`[ApiKeyController] Updated API key "${apiKey.name}"`)
|
Logger.info(`[ApiKeyController] Updated API key "${apiKey.name}"`)
|
||||||
} else {
|
} else {
|
||||||
Logger.info(`[ApiKeyController] No updates needed to API key "${apiKey.name}"`)
|
Logger.info(`[ApiKeyController] No updates needed to API key "${apiKey.name}"`)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue