Fix changed token (#2439)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2022-12-15 11:44:59 +06:00 committed by GitHub
parent 94cbd80336
commit a9d839245d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 22 deletions

View File

@ -277,7 +277,6 @@ export async function selectWorkspace (workspace: string): Promise<[Status, Work
}
export function setLoginInfo (loginInfo: WorkspaceLoginInfo): void {
setMetadata(login.metadata.LoginToken, loginInfo.token)
const tokens: Record<string, string> = fetchMetadataLocalStorage(login.metadata.LoginTokens) ?? {}
tokens[loginInfo.workspace] = loginInfo.token
@ -290,6 +289,7 @@ export function navigateToWorkspace (workspace: string, loginInfo?: WorkspaceLog
if (loginInfo == null) {
return
}
setMetadata(login.metadata.LoginToken, loginInfo.token)
setLoginInfo(loginInfo)
if (navigateUrl !== undefined) {

View File

@ -14,33 +14,16 @@
-->
<script lang="ts">
import login from '@hcengineering/login'
import {
getWorkspaces,
selectWorkspace,
Workspace,
navigateToWorkspace,
setLoginInfo
} from '@hcengineering/login-resources'
import { navigateToWorkspace, selectWorkspace, setLoginInfo, Workspace } from '@hcengineering/login-resources'
import { getEmbeddedLabel } from '@hcengineering/platform'
import { navigate, Menu, locationToUrl } from '@hcengineering/ui'
import { Loading, locationToUrl, Menu, navigate } from '@hcengineering/ui'
import { workbenchId } from '@hcengineering/workbench'
import { onMount } from 'svelte'
import workbench from '../plugin'
export let workspaces: Workspace[]
let _workspaces: Workspace[] = []
onMount(() => {
if (workspaces.length === 0) {
getWorkspaces().then((ws: Workspace[]) => (_workspaces = ws))
} else {
_workspaces = workspaces
}
})
$: actions = [
..._workspaces.map((w) => ({
...workspaces.map((w) => ({
label: getEmbeddedLabel(w.workspace),
action: async () => {
const loginInfo = (await selectWorkspace(w.workspace))[1]
@ -76,4 +59,8 @@
]
</script>
<Menu {actions} on:close />
{#if workspaces.length}
<Menu {actions} on:close />
{:else}
<Loading />
{/if}