add runtime feature adjust config for enable/disable some feature such phone verify in local develop enviroment

pull/40/head
alimy 3 years ago
parent 6a78a26dc9
commit e82fa0db2f

@ -10,6 +10,8 @@ App: # APP基础设置项
SmsJuheTplVal: "#code#=%d&#m#=%d"
AlipayAppID:
AlipayPrivateKey:
Runtime: # App运行时功能调节
DisablePhoneVerify: False # 禁止绑定手机号码时验证短信验证码为true时任意验证码都可以通过验证
Server: # 服务设置
RunMode: debug
HttpIp: 0.0.0.0

@ -10,6 +10,7 @@ import (
var (
ServerSetting *setting.ServerSettingS
AppSetting *setting.AppSettingS
RuntimeSetting *setting.RuntimeSettingS
DatabaseSetting *setting.DatabaseSettingS
RedisSetting *setting.RedisSettingS
SearchSetting *setting.SearchSettingS

@ -41,6 +41,10 @@ func setupSetting() error {
if err != nil {
return err
}
err = setting.ReadSection("Runtime", &global.RuntimeSetting)
if err != nil {
return err
}
err = setting.ReadSection("Log", &global.LoggerSetting)
if err != nil {
return err

@ -248,11 +248,12 @@ func BindUserPhone(c *gin.Context) {
}
// 验证短信验证码
err := svc.CheckPhoneCaptcha(param.Phone, param.Captcha)
if err != nil {
global.Logger.Errorf("svc.CheckPhoneCaptcha err: %v\n", err)
response.ToErrorResponse(err)
return
if !global.RuntimeSetting.DisablePhoneVerify {
if err := svc.CheckPhoneCaptcha(param.Phone, param.Captcha); err != nil {
global.Logger.Errorf("svc.CheckPhoneCaptcha err: %v\n", err)
response.ToErrorResponse(err)
return
}
}
// 执行绑定

@ -51,6 +51,10 @@ type AppSettingS struct {
AlipayPrivateKey string
}
type RuntimeSettingS struct {
DisablePhoneVerify bool
}
type SearchSettingS struct {
ZincHost string
ZincIndex string

Loading…
Cancel
Save