mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-28 12:56:35 +08:00
fix code
This commit is contained in:
parent
dfee8891d3
commit
1747ae8984
@ -42,7 +42,11 @@ func SetPassword(c *gin.Context) {
|
||||
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)
|
||||
if LimitError != nil {
|
||||
log.Error(params.OperationID, utils.GetSelfFuncName(), LimitError, ip)
|
||||
@ -133,7 +137,7 @@ func SetPassword(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
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 {
|
||||
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()})
|
||||
|
@ -12,12 +12,13 @@ func GetRegister(account, areaCode, userID string) (*db.Register, 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{
|
||||
Account: account,
|
||||
Password: password,
|
||||
Ex: ex,
|
||||
UserID: userID,
|
||||
RegisterIP: ip,
|
||||
AreaCode: areaCode,
|
||||
}
|
||||
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) {
|
||||
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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user