Skip to content

Commit

Permalink
feat: add account sign up mode config (#172) (#181)
Browse files Browse the repository at this point in the history
* chore: add account sign up mode config (#172)

* fix: k8s ACCOUNT_SIGNUP_MODE config (#172)
  • Loading branch information
cccy0 authored Jul 12, 2022
1 parent 2f2e84e commit 60195b2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions deploy/docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ services:
LOG_LEVEL: ${LOG_LEVEL:-debug}
APP_SERVICE_IMAGE: ${APP_SERVICE_IMAGE:-lafyun/app-service:latest}
ACCOUNT_DEFAULT_APP_QUOTA: ${ACCOUNT_DEFAULT_APP_QUOTA:-2}
ACCOUNT_SIGNUP_MODE: ${ACCOUNT_SIGNUP_MODE:-0}
APP_SERVICE_DEPLOY_HOST: ${DEPLOY_DOMAIN:?err}:${PUBLISH_PORT:-8080}
APP_SERVICE_DEPLOY_URL_SCHEMA: ${APP_SERVICE_DEPLOY_URL_SCHEMA}
MINIO_ACCESS_KEY: ${MINIO_ROOT_USER}
Expand Down
1 change: 1 addition & 0 deletions deploy/kubernetes/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ metadata:
data:
image: "docker.io/lafyun/app-service:0.8.0-alpha.9"
default-app-quota-created-per-user: "5"
account-signup-mode: "0"
kube-namespace-of-app-services: 'laf-apps'
system-appid: "000000"
appid-length: "6"
7 changes: 6 additions & 1 deletion deploy/kubernetes/sys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ spec:
configMapKeyRef:
name: app-service
key: default-app-quota-created-per-user
- name: ACCOUNT_SIGNUP_MODE
valueFrom:
configMapKeyRef:
name: app-service
key: account-signup-mode
- name: APP_SERVICE_DEPLOY_HOST
valueFrom:
configMapKeyRef:
Expand Down Expand Up @@ -156,4 +161,4 @@ spec:
key: minio-region-name
ports:
- name: http
containerPort: 9000
containerPort: 9000
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ services:
SYS_SERVER_SECRET_SALT: Rewrite_Your_Own_Secret_Salt_abcdefg1234567
LOG_LEVEL: debug
ACCOUNT_DEFAULT_APP_QUOTA: 5
ACCOUNT_SIGNUP_MODE: 0
APP_SERVICE_IMAGE: lafyun/app-service:latest
APP_SERVICE_DEPLOY_HOST: 127-0-0-1.nip.io:8080 # `*.127-0-0-1.nip.io` always resolved to 127.0.0.1, used to local development
APP_SERVICE_DEPLOY_URL_SCHEMA: 'http'
Expand Down
10 changes: 10 additions & 0 deletions packages/system-server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ export default class Config {
return Number(value)
}

/**
* Account registration mode
* 0(Default): Unlimited registration
* 1: Prohibit registration
*/
static get ACCOUNT_SIGNUP_MODE(): number {
const value = process.env.ACCOUNT_SIGNUP_MODE ?? 0
return Number(value)
}

/**
* The host to access the app service
* For example, if set this to `lafyun.com`, then you can access app service by format `[appid].lafyun.com`:
Expand Down
4 changes: 4 additions & 0 deletions packages/system-server/src/handler/account/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import Config from '../../config'
* The handler of sign up
*/
export async function handleSignUp(req: Request, res: Response) {
const signUpMode = Config.ACCOUNT_SIGNUP_MODE
if (signUpMode === 1) {
return res.send({ error: 'account prohibit registration' })
}

const db = DatabaseAgent.db

Expand Down

0 comments on commit 60195b2

Please sign in to comment.