Skip to content

Commit

Permalink
feat: LOGIN_PASSWORD_ONLY env variable for self hosting without mail …
Browse files Browse the repository at this point in the history
…server
  • Loading branch information
acheong08 committed Nov 3, 2024
1 parent 8bd4590 commit f0d8ad2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions dev/prod/src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ export async function configurePlatform() {

setMetadata(login.metadata.AccountsUrl, config.ACCOUNTS_URL)
setMetadata(login.metadata.DisableSignUp, config.DISABLE_SIGNUP === 'true')
setMetadata(login.metadata.LoginPasswordOnly, config.LOGIN_PASSWORD_ONLY === 'true')
setMetadata(presentation.metadata.FilesURL, config.FILES_URL)
setMetadata(presentation.metadata.UploadURL, config.UPLOAD_URL)
setMetadata(presentation.metadata.CollaboratorUrl, config.COLLABORATOR_URL)
Expand Down
3 changes: 2 additions & 1 deletion plugins/login-resources/src/components/LoginApp.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
export let page: Pages = 'signup'
const signUpDisabled = getMetadata(login.metadata.DisableSignUp) ?? false
const loginPasswordOnly = getMetadata(login.metadata.LoginPasswordOnly) ?? false
let navigateUrl: string | undefined
onDestroy(location.subscribe(updatePageLoc))
Expand Down Expand Up @@ -135,7 +136,7 @@
<Scroller padding={'1rem 0'}>
<div class="form-content">
{#if page === 'login'}
<LoginForm {navigateUrl} {signUpDisabled} />
<LoginForm {navigateUrl} {signUpDisabled} {loginPasswordOnly} />
{:else if page === 'signup'}
<SignupForm {signUpDisabled} />
{:else if page === 'createWorkspace'}
Expand Down
5 changes: 5 additions & 0 deletions plugins/login-resources/src/components/LoginForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@
export let navigateUrl: string | undefined = undefined
export let signUpDisabled = false
export let loginPasswordOnly = false
let method: LoginMethods = LoginMethods.Otp
if (loginPasswordOnly === true) {
method = LoginMethods.Password
}
function changeMethod (event: CustomEvent<LoginMethods>): void {
method = event.detail
}
Expand Down
1 change: 1 addition & 0 deletions plugins/login/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default plugin(loginId, {
LastToken: '' as Metadata<string>,
LoginEndpoint: '' as Metadata<string>,
LoginEmail: '' as Metadata<string>,
LoginPasswordOnly: '' as Metadata<boolean>,
DisableSignUp: '' as Metadata<boolean>
},
component: {
Expand Down
5 changes: 4 additions & 1 deletion server/front/src/starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ export function startFront (ctx: MeasureContext, extraConfig?: Record<string, st

const disableSignUp = process.env.DISABLE_SIGNUP

const loginPasswordOnly = process.env.LOGIN_PASSWORD_ONLY

const config = {
elasticUrl,
storageAdapter,
Expand All @@ -137,7 +139,8 @@ export function startFront (ctx: MeasureContext, extraConfig?: Record<string, st
previewConfig,
uploadConfig,
pushPublicKey,
disableSignUp
disableSignUp,
loginPasswordOnly
}
console.log('Starting Front service with', config)
const shutdown = start(ctx, config, SERVER_PORT, extraConfig)
Expand Down

0 comments on commit f0d8ad2

Please sign in to comment.