mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2025-03-30 05:20:55 +03:00
fix: redirect to login when auth expires #607
This commit is contained in:
parent
607eb3b3d5
commit
0cc22ae1ea
3 changed files with 27 additions and 25 deletions
17
README.md
17
README.md
|
@ -4,20 +4,13 @@
|
||||||
<p>The sleekest looking WebUI for qBittorrent made with Vue.js!</p>
|
<p>The sleekest looking WebUI for qBittorrent made with Vue.js!</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||

|
 
|
||||||

|
|
||||||

|

|
||||||
|
|
||||||

|
 
|
||||||

|
 
|
||||||

|
 
|
||||||

|
 
|
||||||

|
|
||||||

|
|
||||||

|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import axios from 'axios'
|
import axios, { AxiosError } from 'axios'
|
||||||
import type { AxiosInstance } from 'axios'
|
import type { AxiosInstance } from 'axios'
|
||||||
import type {
|
import type {
|
||||||
ApplicationVersion,
|
ApplicationVersion,
|
||||||
|
@ -81,7 +81,7 @@ export class QBitApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMainData(rid?: number): Promise<MainDataResponse> {
|
async getMainData(rid?: number): Promise<MainDataResponse> {
|
||||||
return this.axios.get('/sync/maindata', { params: { rid } }).then(res => res.data)
|
return this.axios.get('/sync/maindata', { params: { rid } }).then(res => res.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
async toggleSpeedLimitsMode(): Promise<void> {
|
async toggleSpeedLimitsMode(): Promise<void> {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import type { ModalTemplate, StoreState } from '@/types/vuetorrent'
|
||||||
import Torrent from '@/models/Torrent'
|
import Torrent from '@/models/Torrent'
|
||||||
import type { AppPreferences } from '@/types/qbit/models'
|
import type { AppPreferences } from '@/types/qbit/models'
|
||||||
import { Status } from '@/models'
|
import { Status } from '@/models'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
SET_APP_VERSION(state: StoreState, version: string) {
|
SET_APP_VERSION(state: StoreState, version: string) {
|
||||||
|
@ -52,20 +53,28 @@ export default {
|
||||||
state.authenticated = payload
|
state.authenticated = payload
|
||||||
},
|
},
|
||||||
updateMainData: async (state: StoreState) => {
|
updateMainData: async (state: StoreState) => {
|
||||||
const response = await qbit.getMainData(state.rid || undefined)
|
try {
|
||||||
state.rid = response.rid || undefined
|
const response = await qbit.getMainData(state.rid || undefined)
|
||||||
|
state.rid = response.rid || undefined
|
||||||
|
|
||||||
state.status = new Status(response.server_state)
|
state.status = new Status(response.server_state)
|
||||||
Tags.update(response)
|
Tags.update(response)
|
||||||
Graph.shiftValues()
|
Graph.shiftValues()
|
||||||
|
|
||||||
// fetch torrent data
|
// fetch torrent data
|
||||||
state.sort_options.isCustomSortEnabled = Torrent.computedValues.indexOf(state.sort_options.sort) !== -1
|
state.sort_options.isCustomSortEnabled = Torrent.computedValues.indexOf(state.sort_options.sort) !== -1
|
||||||
const data = await qbit.getTorrents(state.sort_options)
|
const data = await qbit.getTorrents(state.sort_options)
|
||||||
|
|
||||||
Trackers.update(data)
|
Trackers.update(data)
|
||||||
Torrents.update(data)
|
Torrents.update(data)
|
||||||
DocumentTitle.update()
|
DocumentTitle.update()
|
||||||
|
} catch (error: any) {
|
||||||
|
if(error?.response?.status === 403){
|
||||||
|
console.error("No longer authtenticated, logging out...")
|
||||||
|
state.authenticated = false
|
||||||
|
router.push({ name: 'login' })
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
FETCH_SETTINGS: async (state: StoreState, settings: AppPreferences) => {
|
FETCH_SETTINGS: async (state: StoreState, settings: AppPreferences) => {
|
||||||
state.settings = settings
|
state.settings = settings
|
||||||
|
|
Loading…
Add table
Reference in a new issue