Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release

This commit is contained in:
skiffer-git
2022-09-18 10:51:07 +08:00
7 changed files with 74 additions and 24 deletions
+2
View File
@@ -208,6 +208,8 @@ type config struct {
Enable bool `yaml:"enable"`
Intent string `yaml:"intent"`
MasterSecret string `yaml:"masterSecret"`
ChannelID string `yaml:"channelID"`
ChannelName string `yaml:"channelName"`
}
Fcm struct {
ServiceAccount string `yaml:"serviceAccount"`
+1 -1
View File
@@ -337,4 +337,4 @@ const StatisticsTimeInterval = 60
const MaxNotificationNum = 100
const CurrentVersion = "v2.3.3-rc0"
const CurrentVersion = "v2.3.3"
@@ -26,13 +26,22 @@ func IsLimitLoginIp(LoginIp string) (bool, error) {
return count > 0, nil
}
func IsLimitUserLoginIp(userID string, LoginIp string) (bool, error) {
func IsLimitUserLoginIp(userID string, loginIp string) (limit bool, err error) {
//如果已经存在则放行
var count int64
if err := db.DB.MysqlDB.DefaultGormDB().Table("user_ip_limits").Where("ip=? and user_id=?", LoginIp, userID).Count(&count).Error; err != nil {
return false, err
result := db.DB.MysqlDB.DefaultGormDB().Table("user_ip_limits").Where("user_id=?", userID).Count(&count)
if err := result.Error; err != nil {
return true, err
}
return count == 0, nil
if count < 1 {
return false, nil
}
result = db.DB.MysqlDB.DefaultGormDB().Table("user_ip_limits").Where("user_id=? and ip = ?", userID, loginIp).Count(&count)
if err := result.Error; err != nil {
return true, err
}
return count > 0, nil
}
func QueryIPLimits(ip string) (*db.IpLimit, error) {