mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-27 20:30:40 +08:00
fix code
This commit is contained in:
parent
dfee8891d3
commit
1747ae8984
@ -42,7 +42,11 @@ func SetPassword(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var ip string
|
ip := c.Request.Header.Get("X-Forward-For")
|
||||||
|
if ip == "" {
|
||||||
|
ip = c.ClientIP()
|
||||||
|
}
|
||||||
|
log.NewDebug(params.OperationID, utils.GetSelfFuncName(), "ip:", ip)
|
||||||
Limited, LimitError := imdb.IsLimitRegisterIp(ip)
|
Limited, LimitError := imdb.IsLimitRegisterIp(ip)
|
||||||
if LimitError != nil {
|
if LimitError != nil {
|
||||||
log.Error(params.OperationID, utils.GetSelfFuncName(), LimitError, ip)
|
log.Error(params.OperationID, utils.GetSelfFuncName(), LimitError, ip)
|
||||||
@ -133,7 +137,7 @@ func SetPassword(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info(params.OperationID, "begin store mysql", account, params.Password, "info", params.FaceURL, params.Nickname)
|
log.Info(params.OperationID, "begin store mysql", account, params.Password, "info", params.FaceURL, params.Nickname)
|
||||||
err = imdb.SetPassword(account, params.Password, params.Ex, userID, params.AreaCode)
|
err = imdb.SetPassword(account, params.Password, params.Ex, userID, params.AreaCode, ip)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(params.OperationID, "set phone number password error", account, "err", err.Error())
|
log.NewError(params.OperationID, "set phone number password error", account, "err", err.Error())
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": err.Error()})
|
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": err.Error()})
|
||||||
|
@ -12,13 +12,14 @@ func GetRegister(account, areaCode, userID string) (*db.Register, error) {
|
|||||||
userID, "", account, account, areaCode).Take(&r).Error
|
userID, "", account, account, areaCode).Take(&r).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetPassword(account, password, ex, userID, areaCode string) error {
|
func SetPassword(account, password, ex, userID, areaCode, ip string) error {
|
||||||
r := db.Register{
|
r := db.Register{
|
||||||
Account: account,
|
Account: account,
|
||||||
Password: password,
|
Password: password,
|
||||||
Ex: ex,
|
Ex: ex,
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
AreaCode: areaCode,
|
RegisterIP: ip,
|
||||||
|
AreaCode: areaCode,
|
||||||
}
|
}
|
||||||
return db.DB.MysqlDB.DefaultGormDB().Table("registers").Create(&r).Error
|
return db.DB.MysqlDB.DefaultGormDB().Table("registers").Create(&r).Error
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ func IsLimitUserLoginIp(userID string, LoginIp string) (bool, error) {
|
|||||||
|
|
||||||
func QueryIPLimits(ip string) (*db.IpLimit, error) {
|
func QueryIPLimits(ip string) (*db.IpLimit, error) {
|
||||||
var ipLimit db.IpLimit
|
var ipLimit db.IpLimit
|
||||||
err := db.DB.MysqlDB.DefaultGormDB().Model(&db.IpLimit{}).Where("ip=?", ip).First(&ip).Error
|
err := db.DB.MysqlDB.DefaultGormDB().Model(&db.IpLimit{}).Where("ip=?", ip).Find(&ip).Error
|
||||||
return &ipLimit, err
|
return &ipLimit, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user