fix
Some checks failed
Deploy / deploy (build, debian, 22) (push) Has been cancelled
Deploy / deploy (build:staging, school, 8822) (push) Has been cancelled

This commit is contained in:
2026-06-10 20:29:40 -06:00
parent 6f99688667
commit 596ceec880
2 changed files with 10 additions and 1 deletions

View File

@@ -103,6 +103,7 @@ import { ref, computed, onMounted } from "vue"
import { Account } from "../api" import { Account } from "../api"
import { loginModal } from "../store/modal" import { loginModal } from "../store/modal"
import { user } from "../store/user" import { user } from "../store/user"
import { router } from "../router"
// Tab state // Tab state
const activeTab = ref("student") const activeTab = ref("student")
@@ -190,6 +191,9 @@ async function submitStudent() {
user.role = data.role user.role = data.role
user.loaded = true user.loaded = true
loginModal.value = false loginModal.value = false
router.replace(
window.location.pathname + window.location.search + window.location.hash,
)
} catch { } catch {
showStudentError.value = true showStudentError.value = true
} finally { } finally {
@@ -207,6 +211,9 @@ async function submitAdmin() {
user.role = data.role user.role = data.role
user.loaded = true user.loaded = true
loginModal.value = false loginModal.value = false
router.replace(
window.location.pathname + window.location.search + window.location.hash,
)
} catch { } catch {
showAdminError.value = true showAdminError.value = true
} finally { } finally {

View File

@@ -3,6 +3,7 @@ import { loginModal } from "./store/modal"
import Workspace from "./pages/Workspace.vue" import Workspace from "./pages/Workspace.vue"
import { STORAGE_KEY } from "./utils/const" import { STORAGE_KEY } from "./utils/const"
import { authed } from "./store/user"
const routes = [ const routes = [
{ path: "/", name: "home", component: Workspace, meta: { auth: true } }, { path: "/", name: "home", component: Workspace, meta: { auth: true } },
@@ -75,7 +76,8 @@ export const router = createRouter({
}) })
router.beforeEach((to) => { router.beforeEach((to) => {
const isLoggedIn = localStorage.getItem(STORAGE_KEY.LOGIN) === "true" const isLoggedIn =
authed.value || localStorage.getItem(STORAGE_KEY.LOGIN) === "true"
if (to.meta.auth && !isLoggedIn) { if (to.meta.auth && !isLoggedIn) {
loginModal.value = true loginModal.value = true
return false return false