diff --git a/client/pages/account.vue b/client/pages/account.vue
index c371a969d..8323772a5 100644
--- a/client/pages/account.vue
+++ b/client/pages/account.vue
@@ -77,8 +77,7 @@
| {{ $strings.LabelDeviceInfo }} |
{{ $strings.LabelIpAddress }} |
- {{ $strings.LabelLastUpdate }} |
- |
+ {{ $strings.LabelLastUpdate }} |
|
@@ -92,23 +91,13 @@
|
{{ session.ipAddress || '-' }}
|
-
+ |
{{ $dateDistanceFromNow(session.updatedAt) }}
|
-
-
-
-
- |
-
-
-
{{ $getString('LabelPaginationPageXOfY', [authSessionsPage + 1, authSessionsNumPages]) }}
-
-
@@ -133,11 +122,6 @@ export default {
changingPassword: false,
loggingOut: false,
authSessions: [],
- authSessionsPage: 0,
- authSessionsNumPages: 0,
- authSessionsItemsPerPage: 10,
- loadingAuthSessions: false,
- deletingSessionId: null,
selectedLanguage: '',
newEReaderDevice: {
name: '',
@@ -301,67 +285,15 @@ export default {
ereaderDevicesUpdated(ereaderDevices) {
this.ereaderDevices = ereaderDevices
},
- loadAuthSessions(page = 0) {
- if (this.loadingAuthSessions) return
- if (page < 0) return
- if (this.authSessionsNumPages > 0 && page > this.authSessionsNumPages - 1) return
-
- this.loadingAuthSessions = true
+ loadAuthSessions() {
this.$axios
- .$get(`/api/me/sessions?page=${page}&itemsPerPage=${this.authSessionsItemsPerPage}`)
+ .$get('/api/me/sessions')
.then((data) => {
this.authSessions = data.sessions || []
- this.authSessionsPage = data.page ?? page
- this.authSessionsNumPages = data.numPages ?? 0
})
.catch((error) => {
console.error('Failed to load sessions', error)
})
- .finally(() => {
- this.loadingAuthSessions = false
- })
- },
- prevAuthSessionsPage() {
- if (this.authSessionsPage <= 0) return
- this.loadAuthSessions(this.authSessionsPage - 1)
- },
- nextAuthSessionsPage() {
- if (this.authSessionsPage >= this.authSessionsNumPages - 1) return
- this.loadAuthSessions(this.authSessionsPage + 1)
- },
- deleteAuthSessionClick(session) {
- this.$store.commit('globals/setConfirmPrompt', {
- message: this.$getString('MessageConfirmLogoutDevice', [this.getSessionDeviceLabel(session)]),
- callback: (confirmed) => {
- if (confirmed) this.deleteAuthSession(session)
- },
- type: 'yesNo'
- })
- },
- deleteAuthSession(session) {
- // Call logout instead for current session
- if (session.current) {
- this.logout(false)
- return
- }
-
- this.deletingSessionId = session.id
- this.$axios
- .$delete(`/api/me/sessions/${session.id}`)
- .then(() => {
- if (this.authSessions.length === 1 && this.authSessionsPage > 0) {
- this.loadAuthSessions(this.authSessionsPage - 1)
- } else {
- this.loadAuthSessions(this.authSessionsPage)
- }
- })
- .catch((error) => {
- console.error('Failed to delete session', error)
- this.$toast.error(this.$strings.ToastFailedToDelete)
- })
- .finally(() => {
- this.deletingSessionId = null
- })
},
getSessionDeviceLabel(session) {
const deviceInfo = session.deviceInfo
diff --git a/client/strings/en-us.json b/client/strings/en-us.json
index d9d6325e4..684927124 100644
--- a/client/strings/en-us.json
+++ b/client/strings/en-us.json
@@ -777,7 +777,6 @@
"MessageConfirmDeleteSession": "Are you sure you want to delete this session?",
"MessageConfirmEmbedMetadataInAudioFiles": "Are you sure you want to embed metadata in {0} audio files?",
"MessageConfirmForceReScan": "Are you sure you want to force re-scan?",
- "MessageConfirmLogoutDevice": "Are you sure you want to log out of \"{0}\"?",
"MessageConfirmMarkAllEpisodesFinished": "Are you sure you want to mark all episodes as finished?",
"MessageConfirmMarkAllEpisodesNotFinished": "Are you sure you want to mark all episodes as not finished?",
"MessageConfirmMarkItemFinished": "Are you sure you want to mark \"{0}\" as finished?",
diff --git a/server/controllers/MeController.js b/server/controllers/MeController.js
index ca600d373..b8f378bfa 100644
--- a/server/controllers/MeController.js
+++ b/server/controllers/MeController.js
@@ -4,7 +4,7 @@ const Logger = require('../Logger')
const SocketAuthority = require('../SocketAuthority')
const Database = require('../Database')
const { sort } = require('../libs/fastSort')
-const { toNumber, isNullOrNaN, isUUID } = require('../utils/index')
+const { toNumber, isNullOrNaN } = require('../utils/index')
const userStats = require('../utils/queries/userStats')
const parseUserAgent = require('../utils/parsers/parseUserAgent')
@@ -35,30 +35,21 @@ class MeController {
* @param {Response} res
*/
async getSessions(req, res) {
- const page = Math.max(0, toNumber(req.query.page, 0))
- const itemsPerPage = Math.max(1, toNumber(req.query.itemsPerPage, 10))
-
if (req.user.isGuest) {
- return res.json({ sessions: [], total: 0, numPages: 0, page, itemsPerPage })
+ return res.json({ sessions: [] })
}
const refreshToken = req.cookies.refresh_token || req.headers['x-refresh-token']
- const { rows, count } = await Database.sessionModel.findAndCountAll({
+ const sessions = await Database.sessionModel.findAll({
where: {
userId: req.user.id,
expiresAt: { [Op.gt]: new Date() }
},
- order: [['updatedAt', 'DESC']],
- limit: itemsPerPage,
- offset: itemsPerPage * page
+ order: [['updatedAt', 'DESC']]
})
res.json({
- total: count,
- numPages: Math.ceil(count / itemsPerPage),
- page,
- itemsPerPage,
- sessions: rows.map((session) => ({
+ sessions: sessions.map((session) => ({
id: session.id,
ipAddress: session.ipAddress,
userAgent: session.userAgent,
@@ -71,38 +62,6 @@ class MeController {
})
}
- /**
- * DELETE: /api/me/sessions/:id
- *
- * @param {RequestWithUser} req
- * @param {Response} res
- */
- async deleteSession(req, res) {
- if (req.user.isGuest) {
- return res.sendStatus(403)
- }
-
- if (!isUUID(req.params.id)) {
- return res.sendStatus(400)
- }
-
- const session = await Database.sessionModel.findOne({
- where: {
- id: req.params.id,
- userId: req.user.id
- }
- })
-
- if (!session) {
- return res.sendStatus(404)
- }
-
- await Database.sessionModel.destroy({ where: { id: session.id } })
- Logger.info(`[MeController] User ${req.user.username} deleted auth session ${session.id}`)
-
- res.sendStatus(200)
- }
-
/**
* GET: /api/me/progress
*
diff --git a/server/routers/ApiRouter.js b/server/routers/ApiRouter.js
index 7c89126b2..3ade851bb 100644
--- a/server/routers/ApiRouter.js
+++ b/server/routers/ApiRouter.js
@@ -172,7 +172,6 @@ class ApiRouter {
//
this.router.get('/me', MeController.getCurrentUser.bind(this))
this.router.get('/me/sessions', MeController.getSessions.bind(this))
- this.router.delete('/me/sessions/:id', MeController.deleteSession.bind(this))
this.router.get('/me/progress', MeController.getAllMediaProgress.bind(this))
this.router.get('/me/bookmarks', MeController.getAllBookmarks.bind(this))
this.router.get('/me/bookmarks/:libraryItemId', MeController.getBookmarksForLibraryItem.bind(this))