Fix wrong merge

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2024-08-01 21:22:42 +07:00
parent f9c3dd38d2
commit bcbc8af9e5
12 changed files with 53 additions and 69 deletions
@@ -18,7 +18,7 @@
setMetadataLocalStorage(login.metadata.LastToken, result.token)
setMetadataLocalStorage(login.metadata.LoginEndpoint, result.endpoint)
setMetadataLocalStorage(login.metadata.LoginEmail, result.email)
await afterConfirm('onboard')
await afterConfirm()
} else {
goTo('login')
}
@@ -51,7 +51,6 @@
import loginBackWebp from '../../img/login_back.webp'
import loginBack2xWebp from '../../img/login_back_2x.webp'
import login from '../plugin'
import OnboardForm from './OnboardForm.svelte'
export let page: Pages = 'signup'
@@ -138,8 +137,6 @@
<LoginForm {navigateUrl} />
{:else if page === 'signup'}
<SignupForm />
{:else if page === 'onboard'}
<OnboardForm />
{:else if page === 'createWorkspace'}
<CreateWorkspaceForm />
{:else if page === 'password'}
@@ -13,7 +13,7 @@
// limitations under the License.
-->
<script lang="ts">
import { LoginInfo, WorkspaceLoginInfo } from '@hcengineering/login'
import login, { LoginInfo, WorkspaceLoginInfo } from '@hcengineering/login'
import { OK } from '@hcengineering/platform'
import { onMount } from 'svelte'
@@ -81,20 +81,26 @@
if (value == null || value === '') return
const index = fields.findIndex(({ id }) => id === target.id)
if (index === -1) return
if (value.length === fields.length) {
pasteOtpCode(value)
} else {
const index = fields.findIndex(({ id }) => id === target.id)
if (index === -1) return
if (Object.values(otpData).every((v) => v !== '')) {
void validateOtp()
return
}
target.value = value[0]
const nextField = fields[index + 1]
if (nextField === undefined) return
if (Object.values(otpData).every((v) => v !== '')) {
void validateOtp()
return
}
const nextInput = formElement?.querySelector(`input[name="${nextField.name}"]`) as HTMLInputElement
if (nextInput != null) {
nextInput.focus()
const nextField = fields[index + 1]
if (nextField === undefined) return
const nextInput = formElement?.querySelector(`input[name="${nextField.name}"]`) as HTMLInputElement
if (nextInput != null) {
nextInput.focus()
}
}
}
@@ -139,9 +145,15 @@
if (e.clipboardData == null) return
const text = e.clipboardData.getData('text')
pasteOtpCode(text)
}
function pasteOtpCode (text: string): boolean {
const digits = text.split('').filter((it) => it !== ' ')
if (digits.length !== fields.length) return
if (digits.length !== fields.length) {
return false
}
let focusName: string | undefined = undefined
@@ -160,6 +172,8 @@
if (Object.values(otpData).every((v) => v !== '')) {
void validateOtp()
}
return true
}
$: if (formElement != null) {
+1 -8
View File
@@ -62,16 +62,9 @@ export const pages = [
'confirm',
'confirmationSend',
'auth',
'login-password',
'onboard'
'login-password'
] as const
export enum OnboardSteps {
Workspace = 'workspace',
User = 'user',
Finish = 'finish'
}
export enum OtpLoginSteps {
Email = 'email',
Otp = 'otp'
+1 -7
View File
@@ -67,12 +67,6 @@ export default mergeIds(loginId, login, {
SentTo: '' as IntlString,
CanFindCode: '' as IntlString,
LoginWithCode: '' as IntlString,
LoginWithPassword: '' as IntlString,
FillInProfile: '' as IntlString,
SetUpPassword: '' as IntlString,
Next: '' as IntlString,
Skip: '' as IntlString,
SignUpCompleted: '' as IntlString,
StartUsingHuly: '' as IntlString
LoginWithPassword: '' as IntlString
}
})
+3 -12
View File
@@ -521,7 +521,7 @@ export async function getInviteLinkId (
): Promise<string> {
const accountsUrl = getMetadata(login.metadata.AccountsUrl)
const exp = expHours * 1000 * 60 * 60
const exp = expHours < 0 ? -1 : expHours * 1000 * 60 * 60
if (accountsUrl === undefined) {
throw new Error('accounts url not specified')
@@ -872,10 +872,10 @@ export function getHref (path: Pages): string {
return host + url
}
export async function afterConfirm (wspage: 'onboard' | 'createWorkspace' = 'createWorkspace'): Promise<void> {
export async function afterConfirm (): Promise<void> {
const joinedWS = await getWorkspaces()
if (joinedWS.length === 0) {
goTo(wspage)
goTo('createWorkspace')
} else if (joinedWS.length === 1) {
const result = (await selectWorkspace(joinedWS[0].workspace, null))[1]
if (result !== undefined) {
@@ -1044,12 +1044,3 @@ export async function doLoginNavigate (
navigate(loc)
}
}
export async function ensureConfirmed (account: LoginInfo): Promise<void> {
if (!account.confirmed) {
const loc = getCurrentLocation()
loc.path[1] = 'confirmationSend'
loc.path.length = 2
navigate(loc)
}
}