Skip to content

Commit

Permalink
Fix password required error code
Browse files Browse the repository at this point in the history
  • Loading branch information
Triple-Z committed Apr 17, 2019
1 parent 9e97c43 commit 0e02b0b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
3 changes: 2 additions & 1 deletion ERRORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@

| Error Code | Error Message (en) | Error Message (zh) |
| :----: | :----: | :----: |
| 20501 | Incorrect password | 密码错误 |
| 20501 | Password incorrect | 密码错误 |
| 20502 | Password required | 需要密码 |
3 changes: 2 additions & 1 deletion common/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,6 @@ var Errors = map[int]string{
20306: "The retrieve code mismatch auth",
20307: "The retrieve code repeat",

20501: "Incorrect password",
20501: "Password incorrect",
20502: "Password required",
}
24 changes: 16 additions & 8 deletions item/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,22 @@ func Validation(c *gin.Context) {
// 验证密码
// 密码加密方式:SHA256( retrieveCode, SHA256(password) )
var valiPass ValiPass
if err := c.ShouldBindJSON(&valiPass); err != nil {
c.JSON(http.StatusUnauthorized, gin.H{
"err_code": 10005,
"message": common.Errors[10005],
})
log.Println(c.ClientIP(), " Cannot get the password from client, return 401 Unauthorized")
return
}
//if err := c.ShouldBindJSON(&valiPass); err != nil {
// c.JSON(http.StatusUnauthorized, gin.H{
// "err_code": 10005,
// "message": common.Errors[10005],
// })
// log.Println(c.ClientIP(), " Cannot get the password from client, return 401 Unauthorized")
// return
//}

common.FuncHandler(c,
c.ShouldBindJSON(&valiPass),
nil,
http.StatusUnauthorized,
20502,
fmt.Sprintf(c.ClientIP(), " Cannot get the password from client, return 401 Unauthorized"),
)

SHA256Password := valiPass.Password
refPassword := curItem.Password
Expand Down

0 comments on commit 0e02b0b

Please sign in to comment.