Fixed error on whiteboard view and login redirection

This commit is contained in:
2026-03-10 21:52:40 +01:00
parent 6a3fd249a4
commit fcb195ddb3
3 changed files with 6 additions and 21 deletions

View File

@@ -33,7 +33,6 @@ export const authService = {
async getMe() : Promise<User> {
const raw = await api.get<any>('/api/User/me')
// backend User may have fields like userName / UserName and email / Email
const userId = raw?.userId ?? ''
const username = raw?.userName ?? raw?.UserName ?? raw?.username ?? raw?.name ?? ''
const email = raw?.email ?? raw?.Email ?? ''

View File

@@ -33,23 +33,6 @@ export const useWhiteboardStore = defineStore('whiteboard', () => {
}
})
async function initializeSession(id: string) {
isLoading.value = true;
error.value = null;
try{
await whiteboardHubService.connect()
isConnected.value = true;
registerHubEvents()
await whiteboardHubService.joinWhiteboard(id)
} catch (e: any) {
error.value = e?.message ?? 'Failed to join whiteboard'
isLoading.value = false
}
}
function registerHubEvents() {
whiteboardHubService.offAll()
@@ -153,7 +136,7 @@ export const useWhiteboardStore = defineStore('whiteboard', () => {
await whiteboardHubService.joinWhiteboard(id)
} catch (e: any) {
error.value = e?.message ?? 'Failed to join whiteboard'
error.value = 'Failed to join whiteboard, please try again'
isLoading.value = false
}
}

View File

@@ -1,9 +1,10 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useRouter, RouterLink } from 'vue-router'
import { useRouter, RouterLink, useRoute } from 'vue-router'
import { useAuthStore } from '@/stores/auth'
const router = useRouter()
const route = useRoute()
const auth = useAuthStore()
const email = ref('')
@@ -16,7 +17,9 @@ async function onSubmit() {
loading.value = true
try {
await auth.login({ email: email.value, password: password.value })
router.push('/')
const redirectPath = route.query.redirect as string || '/'
router.push(redirectPath)
} catch (e: any) {
error.value = e.messages || ['Login failed']
} finally {