mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-20 19:49:17 +08:00
Restrict user login with IP
This commit is contained in:
parent
44e4c59493
commit
630fef29a2
@ -125,8 +125,12 @@ func QueryUserIPLimitLogin(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "GetIpLimitsByUserID error!"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
if len(resp) > 0 {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": "[]"})
|
||||
}
|
||||
|
||||
type AddUserIPLimitLoginReq struct {
|
||||
|
@ -44,7 +44,7 @@ func InsertOneIntoIpLimits(ipLimits db.IpLimit) error {
|
||||
|
||||
func GetIpLimitsLoginByUserID(userID string) ([]db.UserIpLimit, error) {
|
||||
var ips []db.UserIpLimit
|
||||
err := db.DB.MysqlDB.DefaultGormDB().Model(&db.UserIpLimit{}).Where("user_id=?", userID).Take(&ips).Error
|
||||
err := db.DB.MysqlDB.DefaultGormDB().Model(&db.UserIpLimit{}).Where("user_id=?", userID).Find(&ips).Error
|
||||
return ips, err
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user