1
0
Fork 0
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:
Larsluph 2023-11-05 00:53:03 +01:00 committed by Daan Wijns
parent 4eaaa33711
commit b9e7372c8e
3 changed files with 10 additions and 9 deletions

View file

@ -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 = () => {

View file

@ -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()
}

View file

@ -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() {