fix login bug

This commit is contained in:
Ruben Fiszel
2022-06-03 20:52:14 +02:00
parent f8cc9996b7
commit ebea549966
2 changed files with 12 additions and 19 deletions
+1 -18
View File
@@ -31,15 +31,6 @@
'Connection got disposed.'
]
async function redirectIfLoggedIn(): Promise<void> {
try {
await UserService.getCurrentEmail()
goto('/')
} catch {
clearStores()
}
}
async function loadData() {
try {
$usersWorkspaceStore = await WorkspaceService.listUserWorkspaces()
@@ -57,16 +48,8 @@
}
}
async function handleRedirectionsAndLoadData() {
if ($page.url.pathname === '/user/login') {
redirectIfLoggedIn()
} else {
loadData()
}
}
onMount(() => {
handleRedirectionsAndLoadData()
loadData()
window.onunhandledrejection = (event: PromiseRejectionEvent) => {
event.preventDefault()
+11 -1
View File
@@ -2,10 +2,11 @@
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import { faGithub } from '@fortawesome/free-brands-svg-icons'
import { onMount } from 'svelte'
import Icon from 'svelte-awesome'
import { slide } from 'svelte/transition'
import { UserService, WorkspaceService } from '../../gen'
import { userStore, usersWorkspaceStore, workspaceStore } from '../../stores'
import { clearStores, userStore, usersWorkspaceStore, workspaceStore } from '../../stores'
import { getUser, refreshSuperadmin, sendUserToast } from '../../utils'
import CenteredModal from './CenteredModal.svelte'
@@ -42,6 +43,15 @@
}
}
onMount(async () => {
try {
await UserService.getCurrentEmail()
goto('/')
} catch {
clearStores()
}
})
function handleKeyUp(event: KeyboardEvent) {
const key = event.key || event.keyCode