mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2025-03-28 04:21:03 +03:00
perf(login): Add login with query params
This commit is contained in:
parent
4eaaa33711
commit
b9e7372c8e
3 changed files with 10 additions and 9 deletions
src
|
@ -26,16 +26,10 @@ const navbarStore = useNavbarStore()
|
|||
const preferencesStore = usePreferenceStore()
|
||||
const vuetorrentStore = useVueTorrentStore()
|
||||
|
||||
const onLoginPage = computed(() => router.currentRoute.value.name === 'login')
|
||||
const onLoginPage = computed(() => route.name === 'login')
|
||||
|
||||
const checkAuthentication = async () => {
|
||||
await authStore.updateAuthStatus()
|
||||
|
||||
if (!authStore.isAuthenticated && !onLoginPage.value) {
|
||||
await vuetorrentStore.redirectToLogin()
|
||||
} else {
|
||||
redirectOnSuccess()
|
||||
}
|
||||
}
|
||||
|
||||
const blockContextMenu = () => {
|
||||
|
|
|
@ -45,7 +45,14 @@ const redirectOnSuccess = () => {
|
|||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
onMounted(async () => {
|
||||
if (route.query.username && route.query.password) {
|
||||
await authStore.login(
|
||||
route.query.username as string,
|
||||
route.query.password as string
|
||||
)
|
||||
}
|
||||
|
||||
if (authStore.isAuthenticated) {
|
||||
redirectOnSuccess()
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ export const useVueTorrentStore = defineStore(
|
|||
}
|
||||
|
||||
async function redirectToLogin() {
|
||||
await router.push({ name: 'login', query: { redirect: router.currentRoute.value.fullPath } })
|
||||
await router.push({ name: 'login', query: { redirect: router.currentRoute.value.path } })
|
||||
}
|
||||
|
||||
function updateTitle() {
|
||||
|
|
Loading…
Add table
Reference in a new issue