Skip to content

Commit 60195b2

Browse files
authored
feat: add account sign up mode config (#172) (#181)
* chore: add account sign up mode config (#172) * fix: k8s ACCOUNT_SIGNUP_MODE config (#172)
1 parent 2f2e84e commit 60195b2

File tree

6 files changed

+23
-1
lines changed

6 files changed

+23
-1
lines changed

deploy/docker-compose/docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ services:
6464
LOG_LEVEL: ${LOG_LEVEL:-debug}
6565
APP_SERVICE_IMAGE: ${APP_SERVICE_IMAGE:-lafyun/app-service:latest}
6666
ACCOUNT_DEFAULT_APP_QUOTA: ${ACCOUNT_DEFAULT_APP_QUOTA:-2}
67+
ACCOUNT_SIGNUP_MODE: ${ACCOUNT_SIGNUP_MODE:-0}
6768
APP_SERVICE_DEPLOY_HOST: ${DEPLOY_DOMAIN:?err}:${PUBLISH_PORT:-8080}
6869
APP_SERVICE_DEPLOY_URL_SCHEMA: ${APP_SERVICE_DEPLOY_URL_SCHEMA}
6970
MINIO_ACCESS_KEY: ${MINIO_ROOT_USER}

deploy/kubernetes/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ metadata:
6767
data:
6868
image: "docker.io/lafyun/app-service:0.8.0-alpha.9"
6969
default-app-quota-created-per-user: "5"
70+
account-signup-mode: "0"
7071
kube-namespace-of-app-services: 'laf-apps'
7172
system-appid: "000000"
7273
appid-length: "6"

deploy/kubernetes/sys.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ spec:
9797
configMapKeyRef:
9898
name: app-service
9999
key: default-app-quota-created-per-user
100+
- name: ACCOUNT_SIGNUP_MODE
101+
valueFrom:
102+
configMapKeyRef:
103+
name: app-service
104+
key: account-signup-mode
100105
- name: APP_SERVICE_DEPLOY_HOST
101106
valueFrom:
102107
configMapKeyRef:
@@ -156,4 +161,4 @@ spec:
156161
key: minio-region-name
157162
ports:
158163
- name: http
159-
containerPort: 9000
164+
containerPort: 9000

docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ services:
4848
SYS_SERVER_SECRET_SALT: Rewrite_Your_Own_Secret_Salt_abcdefg1234567
4949
LOG_LEVEL: debug
5050
ACCOUNT_DEFAULT_APP_QUOTA: 5
51+
ACCOUNT_SIGNUP_MODE: 0
5152
APP_SERVICE_IMAGE: lafyun/app-service:latest
5253
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
5354
APP_SERVICE_DEPLOY_URL_SCHEMA: 'http'

packages/system-server/src/config.ts

+10
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ export default class Config {
8989
return Number(value)
9090
}
9191

92+
/**
93+
* Account registration mode
94+
* 0(Default): Unlimited registration
95+
* 1: Prohibit registration
96+
*/
97+
static get ACCOUNT_SIGNUP_MODE(): number {
98+
const value = process.env.ACCOUNT_SIGNUP_MODE ?? 0
99+
return Number(value)
100+
}
101+
92102
/**
93103
* The host to access the app service
94104
* For example, if set this to `lafyun.com`, then you can access app service by format `[appid].lafyun.com`:

packages/system-server/src/handler/account/signup.ts

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import Config from '../../config'
1616
* The handler of sign up
1717
*/
1818
export async function handleSignUp(req: Request, res: Response) {
19+
const signUpMode = Config.ACCOUNT_SIGNUP_MODE
20+
if (signUpMode === 1) {
21+
return res.send({ error: 'account prohibit registration' })
22+
}
1923

2024
const db = DatabaseAgent.db
2125

0 commit comments

Comments
 (0)