feat: add support for registing use force use invite code

This commit is contained in:
RockYang
2023-11-24 12:02:28 +08:00
parent 75b4a6dd46
commit 11f3ab8dc7
9 changed files with 83 additions and 48 deletions

View File

@@ -58,13 +58,3 @@ func (h *SmsHandler) SendCode(c *gin.Context) {
resp.SUCCESS(c)
}
type statusVo struct {
EnabledMsgService bool `json:"enabled_msg_service"`
EnabledRegister bool `json:"enabled_register"`
}
// Status check if the message service is enabled
func (h *SmsHandler) Status(c *gin.Context) {
resp.SUCCESS(c, statusVo{EnabledMsgService: h.App.SysConfig.EnabledMsg, EnabledRegister: h.App.SysConfig.EnabledRegister})
}

View File

@@ -71,7 +71,12 @@ func (h *UserHandler) Register(c *gin.Context) {
// 验证邀请码
inviteCode := model.InviteCode{}
if data.InviteCode != "" {
if data.InviteCode == "" {
if h.App.SysConfig.ForceInvite {
resp.ERROR(c, "当前系统设定必须使用邀请码才能注册")
return
}
} else {
res := h.db.Where("code = ?", data.InviteCode).First(&inviteCode)
if res.Error != nil {
resp.ERROR(c, "无效的邀请码")