mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2025-03-31 13:54:34 +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 preferencesStore = usePreferenceStore()
|
||||||
const vuetorrentStore = useVueTorrentStore()
|
const vuetorrentStore = useVueTorrentStore()
|
||||||
|
|
||||||
const onLoginPage = computed(() => router.currentRoute.value.name === 'login')
|
const onLoginPage = computed(() => route.name === 'login')
|
||||||
|
|
||||||
const checkAuthentication = async () => {
|
const checkAuthentication = async () => {
|
||||||
await authStore.updateAuthStatus()
|
await authStore.updateAuthStatus()
|
||||||
|
|
||||||
if (!authStore.isAuthenticated && !onLoginPage.value) {
|
|
||||||
await vuetorrentStore.redirectToLogin()
|
|
||||||
} else {
|
|
||||||
redirectOnSuccess()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const blockContextMenu = () => {
|
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) {
|
if (authStore.isAuthenticated) {
|
||||||
redirectOnSuccess()
|
redirectOnSuccess()
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ export const useVueTorrentStore = defineStore(
|
||||||
}
|
}
|
||||||
|
|
||||||
async function redirectToLogin() {
|
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() {
|
function updateTitle() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue