mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-23 18:00:32 +08:00
Restrict user login with IP
This commit is contained in:
parent
24e7076423
commit
44e4c59493
@ -34,7 +34,7 @@ func QueryIP(c *gin.Context) {
|
|||||||
ips, err := imdb.QueryUserIPLimits(req.IP)
|
ips, err := imdb.QueryUserIPLimits(req.IP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "GetInvitationCode failed", req.IP)
|
log.NewError(req.OperationID, "GetInvitationCode failed", req.IP)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "QueryUserIPLimits error!"})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "QueryUserIPLimits error!"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp.IP = req.IP
|
resp.IP = req.IP
|
||||||
@ -85,7 +85,7 @@ func AddIPLimit(c *gin.Context) {
|
|||||||
LimitTime: time.Time{},
|
LimitTime: time.Time{},
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.IP, req.LimitTime)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.IP, req.LimitTime)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "InsertOneIntoIpLimits error!"})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "InsertOneIntoIpLimits error!"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": ""})
|
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": ""})
|
||||||
@ -122,7 +122,7 @@ func QueryUserIPLimitLogin(c *gin.Context) {
|
|||||||
resp, err := imdb.GetIpLimitsLoginByUserID(req.UserID)
|
resp, err := imdb.GetIpLimitsLoginByUserID(req.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "GetIpLimitsByUserID error!"})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "GetIpLimitsByUserID error!"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
||||||
|
@ -47,9 +47,11 @@ func SetPassword(c *gin.Context) {
|
|||||||
if LimitError != nil {
|
if LimitError != nil {
|
||||||
log.Error(params.OperationID, utils.GetSelfFuncName(), LimitError, ip)
|
log.Error(params.OperationID, utils.GetSelfFuncName(), LimitError, ip)
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": LimitError.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": LimitError.Error()})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if Limited {
|
if Limited {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": "limited"})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": "limited"})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var account string
|
var account string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user