mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 03:22:19 +03:00
Fix login issue (#1112)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
16bd4b983a
commit
3ce4ea076c
@ -17,6 +17,7 @@ import { addLocation } from '@anticrm/platform'
|
||||
|
||||
import login, { loginId } from '@anticrm/login'
|
||||
import workbench, { workbenchId } from '@anticrm/workbench'
|
||||
import uiPlugin from '@anticrm/ui'
|
||||
import { viewId } from '@anticrm/view'
|
||||
import { taskId } from '@anticrm/task'
|
||||
import { contactId } from '@anticrm/contact'
|
||||
@ -73,6 +74,8 @@ export async function configurePlatform() {
|
||||
|
||||
setMetadata(rekoni.metadata.RekoniUrl, process.env.REKONI_URL)
|
||||
|
||||
setMetadata(uiPlugin.metadata.DefaultApplication, workbench.component.WorkbenchApp )
|
||||
|
||||
addLocation(clientId, () => import(/* webpackChunkName: "client" */ '@anticrm/client-resources'))
|
||||
addLocation(loginId, () => import(/* webpackChunkName: "login" */ '@anticrm/login-resources'))
|
||||
addLocation(workbenchId, () => import(/* webpackChunkName: "workbench" */ '@anticrm/workbench-resources'))
|
||||
|
@ -1,10 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { onDestroy } from 'svelte'
|
||||
import { OK } from '@anticrm/platform'
|
||||
import { getMetadata, OK } from '@anticrm/platform'
|
||||
import { PlatformEvent, addEventListener } from '@anticrm/platform'
|
||||
import type { AnyComponent } from '../../types'
|
||||
// import { applicationShortcutKey } from '../../utils'
|
||||
import { location } from '../../location'
|
||||
import { getCurrentLocation, location, navigate } from '../../location'
|
||||
|
||||
import { Theme } from '@anticrm/theme'
|
||||
import Component from '../Component.svelte'
|
||||
@ -16,6 +16,7 @@
|
||||
import ThemeSelector from './ThemeSelector.svelte'
|
||||
import FontSizeSelector from './FontSizeSelector.svelte'
|
||||
import LangSelector from './LangSelector.svelte'
|
||||
import uiPlugin from '../../plugin'
|
||||
|
||||
let application: AnyComponent | undefined
|
||||
|
||||
@ -23,6 +24,15 @@
|
||||
if (loc.path[0]) {
|
||||
application = loc.path[0] as AnyComponent
|
||||
}
|
||||
|
||||
if (application === undefined) {
|
||||
application = getMetadata(uiPlugin.metadata.DefaultApplication)
|
||||
if (application !== undefined) {
|
||||
const loc = getCurrentLocation()
|
||||
loc.path = [application]
|
||||
navigate(loc)
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
let status = OK
|
||||
|
@ -14,8 +14,9 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import type { IntlString, Plugin } from '@anticrm/platform'
|
||||
import type { IntlString, Metadata, Plugin } from '@anticrm/platform'
|
||||
import { plugin } from '@anticrm/platform'
|
||||
import { AnyComponent } from './types'
|
||||
|
||||
/**
|
||||
* @public
|
||||
@ -38,5 +39,8 @@ export default plugin(uiId, {
|
||||
None: '' as IntlString,
|
||||
English: '' as IntlString,
|
||||
Russian: '' as IntlString
|
||||
},
|
||||
metadata: {
|
||||
DefaultApplication: '' as Metadata<AnyComponent>
|
||||
}
|
||||
})
|
||||
|
@ -26,11 +26,15 @@
|
||||
|
||||
export let page: string = 'login'
|
||||
|
||||
let navigateUrl: string | undefined
|
||||
|
||||
const token = fetchMetadataLocalStorage(login.metadata.LoginToken)
|
||||
|
||||
onDestroy(
|
||||
location.subscribe(async (loc) => {
|
||||
page = loc.path[1] ?? (token ? 'selectWorkspace' : 'login')
|
||||
|
||||
navigateUrl = loc.query?.navigateUrl ?? undefined
|
||||
})
|
||||
)
|
||||
</script>
|
||||
@ -38,13 +42,13 @@
|
||||
<div class="container">
|
||||
<div class="panel">
|
||||
{#if page === 'login'}
|
||||
<LoginForm />
|
||||
<LoginForm {navigateUrl} />
|
||||
{:else if page === 'signup'}
|
||||
<SignupForm />
|
||||
{:else if page === 'createWorkspace'}
|
||||
<CreateWorkspaceForm />
|
||||
{:else if page === 'selectWorkspace'}
|
||||
<SelectWorkspace />
|
||||
<SelectWorkspace {navigateUrl} />
|
||||
{:else if page === 'join'}
|
||||
<Join />
|
||||
{/if}
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
import login from '../plugin'
|
||||
|
||||
export let navigateUrl: string | undefined = undefined
|
||||
|
||||
const fields = [
|
||||
{ id: 'email', name: 'username', i18n: login.string.Email },
|
||||
{
|
||||
@ -54,6 +56,9 @@
|
||||
const loc = getCurrentLocation()
|
||||
loc.path[1] = 'selectWorkspace'
|
||||
loc.path.length = 2
|
||||
if (navigateUrl !== undefined) {
|
||||
loc.query = { ...loc.query, navigateUrl }
|
||||
}
|
||||
navigate(loc)
|
||||
}
|
||||
}
|
||||
|
@ -14,15 +14,15 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { Status, Severity, OK } from '@anticrm/platform'
|
||||
|
||||
import { getWorkspaces, selectWorkspace } from '../utils'
|
||||
import { OK, Severity, Status } from '@anticrm/platform'
|
||||
import { Button, getCurrentLocation, Label, navigate, setMetadataLocalStorage } from '@anticrm/ui'
|
||||
|
||||
import workbench from '@anticrm/workbench'
|
||||
import login from '../plugin'
|
||||
import { getWorkspaces, selectWorkspace } from '../utils'
|
||||
import StatusControl from './StatusControl.svelte'
|
||||
|
||||
export let navigateUrl: string | undefined = undefined
|
||||
|
||||
let status = OK
|
||||
|
||||
async function select (workspace: string) {
|
||||
@ -35,9 +35,13 @@
|
||||
setMetadataLocalStorage(login.metadata.LoginToken, result.token)
|
||||
setMetadataLocalStorage(login.metadata.LoginEndpoint, result.endpoint)
|
||||
setMetadataLocalStorage(login.metadata.LoginEmail, result.email)
|
||||
if (navigateUrl !== undefined) {
|
||||
navigate(JSON.parse(decodeURIComponent(navigateUrl)))
|
||||
} else {
|
||||
navigate({ path: [workbench.component.WorkbenchApp] })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createWorkspace (): void {
|
||||
const loc = getCurrentLocation()
|
||||
|
@ -19,7 +19,7 @@ import { getMetadata, getResource } from '@anticrm/platform'
|
||||
import type { Client } from '@anticrm/core'
|
||||
import core from '@anticrm/core'
|
||||
import { setCurrentAccount } from '@anticrm/core'
|
||||
import { navigate, Loading, fetchMetadataLocalStorage, setMetadataLocalStorage } from '@anticrm/ui'
|
||||
import { navigate, Loading, fetchMetadataLocalStorage, setMetadataLocalStorage, getCurrentLocation, locationToUrl } from '@anticrm/ui'
|
||||
|
||||
import client from '@anticrm/client'
|
||||
import login from '@anticrm/login'
|
||||
@ -36,7 +36,7 @@ async function connect (): Promise<Client | undefined> {
|
||||
const email = fetchMetadataLocalStorage(login.metadata.LoginEmail)
|
||||
|
||||
if (token === null || endpoint === null || email === null) {
|
||||
navigate({ path: [login.component.LoginApp] })
|
||||
navigate({ path: [login.component.LoginApp], query: { navigateUrl: encodeURIComponent(JSON.stringify(getCurrentLocation())) } })
|
||||
return
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ async function connect (): Promise<Client | undefined> {
|
||||
setMetadataLocalStorage(login.metadata.LoginToken, null)
|
||||
setMetadataLocalStorage(login.metadata.LoginEndpoint, null)
|
||||
setMetadataLocalStorage(login.metadata.LoginEmail, null)
|
||||
navigate({ path: [login.component.LoginApp] })
|
||||
navigate({ path: [login.component.LoginApp], query: { navigateUrl: encodeURIComponent(JSON.stringify(getCurrentLocation())) } })
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user