diff --git a/server/.dev.vars.example b/server/.dev.vars.example index 16578ef6..eb08641a 100644 --- a/server/.dev.vars.example +++ b/server/.dev.vars.example @@ -1,3 +1,6 @@ +ENVIRONMENT = dev # Set to prod in production env +DEV_EMAIL_RECEIVER=test@mail.com # When the ENVIRONMENT is not set to 'prod', all emails intended for users will be sent to this email address instead. + AUTHORIZATION_CODE_JWT_SECRET=aaa # This must be replace with a strong secret SPA_ACCESS_TOKEN_JWT_SECRET=bbb # This must be replace with a strong secret S2S_ACCESS_TOKEN_JWT_SECRET=ccc # This must be replace with a strong secret diff --git a/server/src/configs/type.ts b/server/src/configs/type.ts index 31f728bc..5c418ad6 100644 --- a/server/src/configs/type.ts +++ b/server/src/configs/type.ts @@ -7,6 +7,8 @@ import { typeConfig } from 'configs' export type Bindings = { DB: D1Database; KV: KVNamespace; + ENVIRONMENT: string; + DEV_EMAIL_RECEIVER: string; AUTHORIZATION_CODE_JWT_SECRET: string; SPA_ACCESS_TOKEN_JWT_SECRET: string; S2S_ACCESS_TOKEN_JWT_SECRET: string; diff --git a/server/src/services/email.tsx b/server/src/services/email.tsx index 70227962..df7614a0 100644 --- a/server/src/services/email.tsx +++ b/server/src/services/email.tsx @@ -16,6 +16,8 @@ export const sendEmailVerificationEmail = async ( SENDGRID_SENDER_ADDRESS: sendgridSender, COMPANY_LOGO_URL: logoUrl, AUTH_SERVER_URL: serverUrl, + ENVIRONMENT: environment, + DEV_EMAIL_RECEIVER: devEmailReceiver, } = env(c) if (!enableEmailVerification || !sendgridApiKey || !sendgridSender || !user.email) return null const verificationCode = cryptoUtil.genRandomString(8) @@ -42,7 +44,7 @@ export const sendEmailVerificationEmail = async ( personalizations: [ { to: [ - { email: user.email }, + { email: environment === 'prod' ? user.email : devEmailReceiver }, ], }, ], diff --git a/server/wrangler.toml b/server/wrangler.toml index 952e8268..ae703c44 100644 --- a/server/wrangler.toml +++ b/server/wrangler.toml @@ -12,12 +12,11 @@ SERVER_SESSION_EXPIRES_IN=1800 # Set to 0 to disable session AUTH_SERVER_URL="http://localhost:8787" # The host url of your CF worker COMPANY_LOGO_URL="https://raw.githubusercontent.com/ValueMelody/melody-homepage/main/logo.jpg" -ENABLE_SIGN_UP=true -ENABLE_NAMES=true -NAMES_IS_REQUIRED=false -ENABLE_USER_APP_CONSENT=true -ENABLE_EMAIL_VERIFICATION=true # Need a valid SENDGRID_API_KEY and SENDGRID_SENDER_ADDRESS in env var -ENABLE_PASSWORD_RESET=true # Need a valid SENDGRID_API_KEY and SENDGRID_SENDER_ADDRESS in env var +ENABLE_SIGN_UP=true # If set to false, sign up will be suppressed +ENABLE_NAMES=true # If set to false, firstName and lastName will not be collected during sign up. +NAMES_IS_REQUIRED=false # If set to true, users will be required to provide their firstName and lastName during sign up. +ENABLE_USER_APP_CONSENT=true # If set to true, users will be required to consent grant permission to each app during authentication. +ENABLE_EMAIL_VERIFICATION=true # To enable email functionality, set valid SENDGRID_API_KEY and SENDGRID_SENDER_ADDRESS environment variables. If set to true, user will receive a verification email upon sign up. [[kv_namespaces]] binding = "KV"