mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 03:40:48 +00:00
Fix login infinity requests (#4865)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
189eb27763
commit
a3e3767108
@ -2,7 +2,7 @@
|
||||
import { LoginInfo, WorkspaceLoginInfo } from '@hcengineering/login'
|
||||
import { setMetadata } from '@hcengineering/platform'
|
||||
import presentation from '@hcengineering/presentation'
|
||||
import { setMetadataLocalStorage } from '@hcengineering/ui'
|
||||
import { Loading, setMetadataLocalStorage } from '@hcengineering/ui'
|
||||
import { onMount } from 'svelte'
|
||||
import login from '../plugin'
|
||||
import { afterConfirm, getSessionLoginInfo, navigateToWorkspace } from '../utils'
|
||||
@ -26,3 +26,5 @@
|
||||
return (info as WorkspaceLoginInfo).workspace !== undefined
|
||||
}
|
||||
</script>
|
||||
|
||||
<Loading />
|
||||
|
@ -22,14 +22,14 @@
|
||||
Loading,
|
||||
Location,
|
||||
navigate,
|
||||
setMetadataLocalStorage,
|
||||
ticker
|
||||
setMetadataLocalStorage
|
||||
} from '@hcengineering/ui'
|
||||
|
||||
import { doLogin, getAccount, getWorkspaces, navigateToWorkspace, selectWorkspace } from '../utils'
|
||||
import Form from './Form.svelte'
|
||||
|
||||
import { LoginInfo } from '@hcengineering/login'
|
||||
import { onMount } from 'svelte'
|
||||
import { recoveryAction } from '../actions'
|
||||
import login from '../plugin'
|
||||
|
||||
@ -53,7 +53,7 @@
|
||||
async function doLoginNavigate (
|
||||
result: LoginInfo | undefined,
|
||||
updateStatus: (status: Status<any>) => void
|
||||
): Promise<boolean> {
|
||||
): Promise<void> {
|
||||
if (result !== undefined) {
|
||||
setMetadata(presentation.metadata.Token, result.token)
|
||||
setMetadataLocalStorage(login.metadata.LastToken, result.token)
|
||||
@ -72,7 +72,7 @@
|
||||
const [loginStatus, result] = await selectWorkspace(workspace)
|
||||
updateStatus(loginStatus)
|
||||
navigateToWorkspace(workspace, result, navigateUrl)
|
||||
return true
|
||||
return
|
||||
}
|
||||
}
|
||||
} catch (err: any) {
|
||||
@ -86,9 +86,7 @@
|
||||
loc.query = { ...loc.query, navigateUrl }
|
||||
}
|
||||
navigate(loc)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
let status = OK
|
||||
@ -107,7 +105,7 @@
|
||||
|
||||
let loading = true
|
||||
|
||||
async function chooseToken (time: number): Promise<void> {
|
||||
async function chooseToken (): Promise<void> {
|
||||
if (getMetadata(presentation.metadata.Token) == null) {
|
||||
const lastToken = fetchMetadataLocalStorage(login.metadata.LastToken)
|
||||
if (lastToken != null) {
|
||||
@ -122,13 +120,16 @@
|
||||
setMetadataLocalStorage(login.metadata.LastToken, null)
|
||||
}
|
||||
}
|
||||
loading = false
|
||||
} else {
|
||||
if (loading) {
|
||||
loading = false
|
||||
}
|
||||
} else if (loading) {
|
||||
loading = false
|
||||
}
|
||||
setTimeout(chooseToken, 1000)
|
||||
}
|
||||
|
||||
$: chooseToken($ticker)
|
||||
onMount(() => chooseToken())
|
||||
</script>
|
||||
|
||||
{#if loading}
|
||||
|
@ -237,7 +237,7 @@ async function getAccountInfo (db: Db, email: string, password: string): Promise
|
||||
return toAccountInfo(account)
|
||||
}
|
||||
|
||||
async function getAccountInfoByToken (db: Db, productId: string, token: string): Promise<AccountInfo> {
|
||||
async function getAccountInfoByToken (db: Db, productId: string, token: string): Promise<LoginInfo> {
|
||||
let email: string = ''
|
||||
try {
|
||||
email = decodeToken(token)?.email
|
||||
@ -248,9 +248,14 @@ async function getAccountInfoByToken (db: Db, productId: string, token: string):
|
||||
if (account === null) {
|
||||
throw new PlatformError(new Status(Severity.ERROR, platform.status.AccountNotFound, { account: email }))
|
||||
}
|
||||
const res = toAccountInfo(account)
|
||||
res.confirmed = res.confirmed ?? true
|
||||
return res
|
||||
const info = toAccountInfo(account)
|
||||
const result = {
|
||||
endpoint: getEndpoint(),
|
||||
email,
|
||||
confirmed: info.confirmed ?? true,
|
||||
token: generateToken(email, getWorkspaceId('', productId), getExtra(info))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user