chore: init users
This commit is contained in:
@ -11,8 +11,10 @@ type Resp struct {
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
func ErrorResp(c *gin.Context, err error, code int) {
|
||||
log.Error(err.Error())
|
||||
func ErrorResp(c *gin.Context, err error, code int, noLog ...bool) {
|
||||
if len(noLog) != 0 && noLog[0] {
|
||||
log.Errorf("%+v", err)
|
||||
}
|
||||
c.JSON(200, Resp{
|
||||
Code: code,
|
||||
Message: err.Error(),
|
||||
|
@ -36,12 +36,12 @@ func Login(c *gin.Context) {
|
||||
}
|
||||
user, err := db.GetUserByName(req.Username)
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 400)
|
||||
common.ErrorResp(c, err, 400, true)
|
||||
return
|
||||
}
|
||||
// validate password
|
||||
if err := user.ValidatePassword(req.Password); err != nil {
|
||||
common.ErrorResp(c, err, 400)
|
||||
common.ErrorResp(c, err, 400, true)
|
||||
loginCache.Set(ip, count+1)
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user