Skip to content

Commit baf2caa

Browse files
committed
[member approval] configurable via environment
1 parent 66c9ec0 commit baf2caa

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

.env.development

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ AUTH_URL="http://localhost:3000"
2323
# AUTH_EE_GOOGLE_CLIENT_ID=""
2424
# AUTH_EE_GOOGLE_CLIENT_SECRET=""
2525

26+
# MEMBER_APPROVAL_REQUIRED="true"
27+
2628
DATA_CACHE_DIR=${PWD}/.sourcebot # Path to the sourcebot cache dir (ex. ~/sourcebot/.sourcebot)
2729
SOURCEBOT_PUBLIC_KEY_PATH=${PWD}/public.pem
2830
# CONFIG_PATH=${PWD}/config.json # Path to the sourcebot config file (if one exists)

docs/docs/configuration/environment-variables.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ The following environment variables allow you to configure your Sourcebot deploy
2222
| `DATABASE_URL` | `postgresql://postgres@ localhost:5432/sourcebot` | <p>Connection string of your Postgres database. By default, a Postgres database is automatically provisioned at startup within the container.</p><p>If you'd like to use a non-default schema, you can provide it as a parameter in the database url </p> |
2323
| `EMAIL_FROM_ADDRESS` | `-` | <p>The email address that transactional emails will be sent from. See [this doc](/docs/configuration/transactional-emails) for more info.</p> |
2424
| `FORCE_ENABLE_ANONYMOUS_ACCESS` | `false` | <p>When enabled, [anonymous access](/docs/configuration/auth/access-settings#anonymous-access) to the organization will always be enabled</p>
25+
| `MEMBER_APPROVAL_REQUIRED` | `true` | <p>When enabled, new users will need approval from an organization owner before they can access your deployment. See [access settings docs](/docs/configuration/auth/access-settings) for more info</p>
2526
| `REDIS_DATA_DIR` | `$DATA_CACHE_DIR/redis` | <p>The data directory for the default Redis instance.</p> |
2627
| `REDIS_URL` | `redis://localhost:6379` | <p>Connection string of your Redis instance. By default, a Redis database is automatically provisioned at startup within the container.</p> |
2728
| `REDIS_REMOVE_ON_COMPLETE` | `0` | <p>Controls how many completed jobs are allowed to remain in Redis queues</p> |

packages/web/src/env.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const env = createEnv({
2121

2222
// Auth
2323
FORCE_ENABLE_ANONYMOUS_ACCESS: booleanSchema.default('false'),
24+
MEMBER_APPROVAL_REQUIRED: booleanSchema.default('true'),
2425

2526
AUTH_SECRET: z.string(),
2627
AUTH_URL: z.string().url(),

packages/web/src/initialize.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ const initSingleTenancy = async () => {
180180
name: SINGLE_TENANT_ORG_NAME,
181181
domain: SINGLE_TENANT_ORG_DOMAIN,
182182
inviteLinkId: crypto.randomUUID(),
183+
memberApprovalRequired: env.MEMBER_APPROVAL_REQUIRED === 'true',
183184
}
184185
});
185186
} else if (!org.inviteLinkId) {
@@ -220,6 +221,17 @@ const initSingleTenancy = async () => {
220221
}
221222
}
222223

224+
// Apply MEMBER_APPROVAL_REQUIRED environment variable setting
225+
const memberApprovalRequired = env.MEMBER_APPROVAL_REQUIRED === 'true';
226+
const org = await getOrgFromDomain(SINGLE_TENANT_ORG_DOMAIN);
227+
if (org) {
228+
await prisma.org.update({
229+
where: { id: org.id },
230+
data: { memberApprovalRequired },
231+
});
232+
logger.info(`Member approval required set to ${memberApprovalRequired} via MEMBER_APPROVAL_REQUIRED environment variable`);
233+
}
234+
223235
// Load any connections defined declaratively in the config file.
224236
const configPath = env.CONFIG_PATH;
225237
if (configPath) {

0 commit comments

Comments
 (0)