Fixed error on whiteboard view and login redirection
This commit is contained in:
@@ -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 ?? ''
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user