Skip to content

Commit 323364b

Browse files
committed
feat(register): Register status can be set (#223)
1 parent f19109c commit 323364b

File tree

11 files changed

+58
-9
lines changed

11 files changed

+58
-9
lines changed

conf/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ lang: "zh-CN"
22
app:
33
web-client: 1 # 1:启用 0:禁用
44
register: false #是否开启注册
5+
register-status: 1 # 注册用户默认状态 1:启用 2:禁用
56
captcha-threshold: 3 # <0:disabled, 0 always, >0:enabled
67
ban-threshold: 0 # 0:disabled, >0:enabled
78
show-swagger: 0 # 1:启用 0:禁用

config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const (
1616
type App struct {
1717
WebClient int `mapstructure:"web-client"`
1818
Register bool `mapstructure:"register"`
19+
RegisterStatus int `mapstructure:"register-status"`
1920
ShowSwagger int `mapstructure:"show-swagger"`
2021
TokenExpire time.Duration `mapstructure:"token-expire"`
2122
WebSso bool `mapstructure:"web-sso"`

http/controller/admin/user.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,22 @@ func (ct *User) Register(c *gin.Context) {
320320
response.Fail(c, 101, errList[0])
321321
return
322322
}
323-
u := service.AllService.UserService.Register(f.Username, f.Email, f.Password)
323+
regStatus := model.StatusCode(global.Config.App.RegisterStatus)
324+
// 注册状态可能未配置,默认启用
325+
if regStatus != model.COMMON_STATUS_DISABLED && regStatus != model.COMMON_STATUS_ENABLE {
326+
regStatus = model.COMMON_STATUS_ENABLE
327+
}
328+
329+
u := service.AllService.UserService.Register(f.Username, f.Email, f.Password, regStatus)
324330
if u == nil || u.Id == 0 {
325331
response.Fail(c, 101, response.TranslateMsg(c, "OperationFailed"))
326332
return
327333
}
334+
if regStatus == model.COMMON_STATUS_DISABLED {
335+
// 需要管理员审核
336+
response.Fail(c, 101, response.TranslateMsg(c, "RegisterSuccessWaitAdminConfirm"))
337+
return
338+
}
328339
// 注册成功后自动登录
329340
ut := service.AllService.UserService.Login(u, &model.LoginLog{
330341
UserId: u.Id,

resources/i18n/en.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,9 @@ other = "Cannot share to self."
147147
[Banned]
148148
description = "Banned."
149149
one = "Banned."
150-
other = "Banned."
150+
other = "Banned."
151+
152+
[RegisterSuccessWaitAdminConfirm]
153+
description = "Register success, wait admin confirm."
154+
one = "Register success, wait admin confirm."
155+
other = "Register success, wait admin confirm."

resources/i18n/es.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,9 @@ other = "No se puede compartir con uno mismo."
156156
[Banned]
157157
description = "Banned."
158158
one = "Prohibido."
159-
other = "Prohibido."
159+
other = "Prohibido."
160+
161+
[RegisterSuccessWaitAdminConfirm]
162+
description = "Register success, wait admin confirm."
163+
one = "Registro exitoso, espere la confirmación del administrador."
164+
other = "Registro exitoso, espere la confirmación del administrador."

resources/i18n/fr.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,9 @@ other = "Impossible de partager avec soi-même."
156156
[Banned]
157157
description = "Banned."
158158
one = "Banni."
159-
other = "Banni."
159+
other = "Banni."
160+
161+
[RegisterSuccessWaitAdminConfirm]
162+
description = "Register success wait admin confirm."
163+
one = "Inscription réussie, veuillez attendre la confirmation de l'administrateur."
164+
other = "Inscription réussie, veuillez attendre la confirmation de l'administrateur."

resources/i18n/ko.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,9 @@ other = "자기 자신에게 공유할 수 없습니다."
150150
[Banned]
151151
description = "Banned."
152152
one = "금지됨."
153-
other = "금지됨."
153+
other = "금지됨."
154+
155+
[RegisterSuccessWaitAdminConfirm]
156+
description = "Register success wait admin confirm."
157+
one = "가입 성공, 관리자 확인 대기 중."
158+
other = "가입 성공, 관리자 확인 대기 중."

resources/i18n/ru.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,9 @@ other = "Нельзя поделиться с собой."
156156
[Banned]
157157
description = "Banned."
158158
one = "Заблокировано."
159-
other = "Заблокировано."
159+
other = "Заблокировано."
160+
161+
[RegisterSuccessWaitAdminConfirm]
162+
description = "Register success wait admin confirm."
163+
one = "Регистрация прошла успешно, ожидайте подтверждения администратора."
164+
other = "Регистрация прошла успешно, ожидайте подтверждения администратора."

resources/i18n/zh_CN.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,9 @@ other = "不能共享给自己。"
149149
[Banned]
150150
description = "Banned."
151151
one = "已被封禁。"
152-
other = "已被封禁。"
152+
other = "已被封禁。"
153+
154+
[RegisterSuccessWaitAdminConfirm]
155+
description = "Register success, wait for admin confirm."
156+
one = "注册成功,请等待管理员审核。"
157+
other = "注册成功,请等待管理员审核。"

resources/i18n/zh_TW.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,9 @@ other = "無法共享給自己。"
149149
[Banned]
150150
description = "Banned."
151151
one = "禁止使用。"
152-
other = "禁止使用。"
152+
other = "禁止使用。"
153+
154+
[RegisterSuccessWaitAdminConfirm]
155+
description = "Register success wait admin confirm."
156+
one = "註冊成功,請等待管理員確認。"
157+
other = "註冊成功,請等待管理員確認。"

0 commit comments

Comments
 (0)