diff --git a/desktop/src/ui/platform.ts b/desktop/src/ui/platform.ts index 74aecd76d97..5e3ef04cde5 100644 --- a/desktop/src/ui/platform.ts +++ b/desktop/src/ui/platform.ts @@ -112,7 +112,7 @@ import github, { githubId } from '@hcengineering/github' import { uiId } from '@hcengineering/ui/src/plugin' import { preferenceId } from '@hcengineering/preference' -function configureI18n (): void { +function configureI18n(): void { // Add localization addStringsLoader(platformId, async (lang: string) => await import(`@hcengineering/platform/lang/${lang}.json`)) addStringsLoader(coreId, async (lang: string) => await import(`@hcengineering/core/lang/${lang}.json`)) @@ -187,7 +187,7 @@ function configureI18n (): void { addStringsLoader(analyticsCollectorId, async (lang: string) => await import(`@hcengineering/analytics-collector-assets/lang/${lang}.json`)) } -export async function configurePlatform (): Promise { +export async function configurePlatform(): Promise { configureI18n() const ipcMain = (window as any).electron as IPCMainExposed @@ -202,6 +202,7 @@ export async function configurePlatform (): Promise { setMetadata(login.metadata.AccountsUrl, config.ACCOUNTS_URL) setMetadata(login.metadata.DisableSignUp, config.DISABLE_SIGNUP === 'true') + setMetadata(login.metadata.DefaultLoginMethod, config.DEFAULT_LOGIN_METHOD) setMetadata(presentation.metadata.UploadURL, config.UPLOAD_URL) setMetadata(presentation.metadata.FilesURL, config.FILES_URL) setMetadata(presentation.metadata.CollaboratorUrl, config.COLLABORATOR_URL) diff --git a/desktop/src/ui/types.ts b/desktop/src/ui/types.ts index 14aca214cb6..70b83b475f7 100644 --- a/desktop/src/ui/types.ts +++ b/desktop/src/ui/types.ts @@ -27,8 +27,9 @@ export interface Config { PRINT_URL?: string PUSH_PUBLIC_KEY: string ANALYTICS_COLLECTOR_URL?: string - AI_URL?:string + AI_URL?: string DISABLE_SIGNUP?: string + DEFAULT_LOGIN_METHOD?: 'otp' | 'password' BRANDING_URL?: string PREVIEW_CONFIG: string UPLOAD_CONFIG: string diff --git a/dev/prod/src/platform.ts b/dev/prod/src/platform.ts index 31c589860e2..aa00d879f7d 100644 --- a/dev/prod/src/platform.ts +++ b/dev/prod/src/platform.ts @@ -152,6 +152,7 @@ export interface Config { TELEGRAM_BOT_URL?: string AI_URL?:string DISABLE_SIGNUP?: string + DEFAULT_LOGIN_METHOD?: 'otp'|'password' // Could be defined for dev environment FRONT_URL?: string PREVIEW_CONFIG?: string @@ -294,6 +295,7 @@ export async function configurePlatform() { setMetadata(login.metadata.AccountsUrl, config.ACCOUNTS_URL) setMetadata(login.metadata.DisableSignUp, config.DISABLE_SIGNUP === 'true') + setMetadata(login.metadata.DefaultLoginMethod, config.DEFAULT_LOGIN_METHOD) setMetadata(presentation.metadata.FilesURL, config.FILES_URL) setMetadata(presentation.metadata.UploadURL, config.UPLOAD_URL) setMetadata(presentation.metadata.CollaboratorUrl, config.COLLABORATOR_URL) diff --git a/plugins/login-resources/src/components/LoginApp.svelte b/plugins/login-resources/src/components/LoginApp.svelte index d0c9b64ef7c..0d823087cae 100644 --- a/plugins/login-resources/src/components/LoginApp.svelte +++ b/plugins/login-resources/src/components/LoginApp.svelte @@ -59,7 +59,7 @@ onDestroy(location.subscribe(updatePageLoc)) - function updatePageLoc (loc: Location): void { + function updatePageLoc(loc: Location): void { const token = getMetadata(presentation.metadata.Token) page = (loc.path[1] as Pages) ?? (token != null ? 'selectWorkspace' : 'login') const allowedUnauthPages: Pages[] = [ @@ -80,7 +80,7 @@ navigateUrl = loc.query?.navigateUrl ?? undefined } - async function chooseToken (): Promise { + async function chooseToken(): Promise { if (page === 'auth') { // token handled by auth page return diff --git a/plugins/login-resources/src/components/LoginForm.svelte b/plugins/login-resources/src/components/LoginForm.svelte index ced1085f38a..1445b7c55cd 100644 --- a/plugins/login-resources/src/components/LoginForm.svelte +++ b/plugins/login-resources/src/components/LoginForm.svelte @@ -18,14 +18,20 @@ import LoginPasswordForm from './LoginPasswordForm.svelte' import LoginOtpForm from './LoginOtpForm.svelte' import BottomActionComponent from './BottomAction.svelte' + import { getMetadata } from '@hcengineering/platform' import login from '../plugin' export let navigateUrl: string | undefined = undefined export let signUpDisabled = false + const defaultLoginMethod = getMetadata(login.metadata.DefaultLoginMethod) ?? 'otp' let method: LoginMethods = LoginMethods.Otp - function changeMethod (event: CustomEvent): void { + if (defaultLoginMethod === 'password') { + method = LoginMethods.Password + } + + function changeMethod(event: CustomEvent): void { method = event.detail } diff --git a/plugins/login/src/index.ts b/plugins/login/src/index.ts index 933a3018208..3d48018eff9 100644 --- a/plugins/login/src/index.ts +++ b/plugins/login/src/index.ts @@ -73,6 +73,7 @@ export default plugin(loginId, { LastToken: '' as Metadata, LoginEndpoint: '' as Metadata, LoginEmail: '' as Metadata, + DefaultLoginMethod: '' as Metadata<'otp' | 'password'>, DisableSignUp: '' as Metadata }, component: { diff --git a/server/front/src/starter.ts b/server/front/src/starter.ts index 2231b174bfa..f732275c44c 100644 --- a/server/front/src/starter.ts +++ b/server/front/src/starter.ts @@ -119,6 +119,8 @@ export function startFront (ctx: MeasureContext, extraConfig?: Record