diff --git a/plugins/login-resources/src/actions.ts b/plugins/login-resources/src/actions.ts new file mode 100644 index 0000000000..4a0bab82bc --- /dev/null +++ b/plugins/login-resources/src/actions.ts @@ -0,0 +1,30 @@ +import { goTo } from './utils' +import login from './plugin' +import { type BottomAction } from '.' + +export const signUpAction: BottomAction = { + caption: login.string.DoNotHaveAnAccount, + i18n: login.string.SignUp, + page: 'signup', + func: () => { + goTo('signup') + } +} + +export const loginAction: BottomAction = { + caption: login.string.AlreadyJoined, + i18n: login.string.LogIn, + page: 'login', + func: () => { + goTo('login', true) + } +} + +export const recoveryAction: BottomAction = { + caption: login.string.ForgotPassword, + i18n: login.string.Recover, + page: 'password', + func: () => { + goTo('password', true) + } +} diff --git a/plugins/login-resources/src/components/Confirmation.svelte b/plugins/login-resources/src/components/Confirmation.svelte index 43a250ed94..4f2d9366c7 100644 --- a/plugins/login-resources/src/components/Confirmation.svelte +++ b/plugins/login-resources/src/components/Confirmation.svelte @@ -13,32 +13,16 @@ // limitations under the License. --> diff --git a/plugins/login-resources/src/components/ConfirmationSend.svelte b/plugins/login-resources/src/components/ConfirmationSend.svelte index c793e52036..90800e3023 100644 --- a/plugins/login-resources/src/components/ConfirmationSend.svelte +++ b/plugins/login-resources/src/components/ConfirmationSend.svelte @@ -13,26 +13,23 @@ // limitations under the License. --> diff --git a/plugins/login-resources/src/components/LoginForm.svelte b/plugins/login-resources/src/components/LoginForm.svelte index 2c7aa383f0..5e347307e6 100644 --- a/plugins/login-resources/src/components/LoginForm.svelte +++ b/plugins/login-resources/src/components/LoginForm.svelte @@ -30,6 +30,7 @@ import Form from './Form.svelte' import { LoginInfo } from '@hcengineering/login' + import { recoveryAction } from '../actions' import login from '../plugin' export let navigateUrl: string | undefined = undefined @@ -51,15 +52,11 @@ async function doLoginNavigate ( result: LoginInfo | undefined, - updateStatus: (status: Status) => void, - token?: string + updateStatus: (status: Status) => void ): Promise { if (result !== undefined) { - if (result.token != null && getMetadata(presentation.metadata.Token) === result.token) { - return false - } - setMetadata(presentation.metadata.Token, token ?? result.token) - setMetadataLocalStorage(login.metadata.LastToken, token ?? result.token) + setMetadata(presentation.metadata.Token, result.token) + setMetadataLocalStorage(login.metadata.LastToken, result.token) setMetadataLocalStorage(login.metadata.LoginEndpoint, result.endpoint) setMetadataLocalStorage(login.metadata.LoginEmail, result.email) @@ -108,16 +105,6 @@ } } - const recoveryAction = { - caption: login.string.ForgotPassword, - i18n: login.string.Recover, - func: () => { - const loc = getCurrentLocation() - loc.path[1] = 'password' - loc.path.length = 2 - navigate(loc) - } - } let loading = true async function chooseToken (time: number): Promise { @@ -125,15 +112,11 @@ const lastToken = fetchMetadataLocalStorage(login.metadata.LastToken) if (lastToken != null) { try { - const info = await getAccount(false, lastToken) + const info = await getAccount(false) if (info !== undefined) { - await doLoginNavigate( - info, - (st) => { - status = st - }, - lastToken - ) + await doLoginNavigate(info, (st) => { + status = st + }) } } catch (err: any) { setMetadataLocalStorage(login.metadata.LastToken, null) diff --git a/plugins/login-resources/src/components/PasswordRequest.svelte b/plugins/login-resources/src/components/PasswordRequest.svelte index 4e69042a60..8072bc16d8 100644 --- a/plugins/login-resources/src/components/PasswordRequest.svelte +++ b/plugins/login-resources/src/components/PasswordRequest.svelte @@ -16,10 +16,12 @@ import { OK, Severity, Status } from '@hcengineering/platform' import { MessageBox } from '@hcengineering/presentation' - import { getCurrentLocation, navigate, showPopup } from '@hcengineering/ui' + import { showPopup } from '@hcengineering/ui' import login from '../plugin' - import { requestPassword } from '../utils' + import { goTo, requestPassword } from '../utils' import Form from './Form.svelte' + import { BottomAction } from '..' + import { signUpAction } from '../actions' const fields = [{ id: 'email', name: 'username', i18n: login.string.Email }] @@ -46,35 +48,20 @@ }, undefined, () => { - const loc = getCurrentLocation() - loc.path[1] = 'login' - navigate(loc) + goTo('login') } ) } } } - const signUpAction = { - caption: login.string.DoNotHaveAnAccount, - i18n: login.string.SignUp, - func: () => { - const loc = getCurrentLocation() - loc.path[1] = 'signup' - loc.path.length = 2 - navigate(loc) - } - } - - const bottomActions = [ + const bottomActions: BottomAction[] = [ { caption: login.string.KnowPassword, i18n: login.string.LogIn, + page: 'login', func: () => { - const loc = getCurrentLocation() - loc.path[1] = 'login' - loc.path.length = 2 - navigate(loc) + goTo('login') } }, signUpAction diff --git a/plugins/login-resources/src/components/PasswordRestore.svelte b/plugins/login-resources/src/components/PasswordRestore.svelte index afb0cab33e..bed8c838b1 100644 --- a/plugins/login-resources/src/components/PasswordRestore.svelte +++ b/plugins/login-resources/src/components/PasswordRestore.svelte @@ -15,11 +15,11 @@
@@ -134,7 +109,14 @@ {/each} {#if workspaces.length === 0 && account?.confirmed === true}
-
{/if} @@ -144,12 +126,12 @@ {#if workspaces.length}
- +
{/if}
- +
{/await} diff --git a/plugins/login-resources/src/components/SignupForm.svelte b/plugins/login-resources/src/components/SignupForm.svelte index f91d0bd3a2..3be00e5918 100644 --- a/plugins/login-resources/src/components/SignupForm.svelte +++ b/plugins/login-resources/src/components/SignupForm.svelte @@ -16,9 +16,9 @@