Skip to content

Commit

Permalink
maybe this
Browse files Browse the repository at this point in the history
  • Loading branch information
probablyjassin committed Nov 12, 2024
1 parent ee7f364 commit 7729a35
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions middleware/isLoggedIn.global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
if (to.fullPath !== "/stundenplan") {
return true
}

console.log(from.fullPath == "/stundenplan")
const username = useCookie("username")
const password = useCookie("password")
const isLoggedIn = useState("isLoggedIn", (() => false) as () => boolean)

if (from.fullPath === "/stundenplan") {
if (from.fullPath == "/stundenplan") {
try {
const test_url = `https://corsproxy.io/?https%3A%2F%2Fselfservice.campus-dual.de%2Fdash%2Fgetcp%3Fuser%3D${username.value}%26hash%3D${password.value}`
const response = await $fetch(test_url)
isLoggedIn.value = !!(response == 0)
return true
} catch (error) {
isLoggedIn.value = false
return
}
}

Expand Down

0 comments on commit 7729a35

Please sign in to comment.