refactor(api): introduce v1 response contract
This commit is contained in:
@@ -24,12 +24,12 @@ func (h *Handler) login(c *gin.Context) {
|
||||
Password string `json:"password"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&input); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid request"})
|
||||
abortWithError(c, http.StatusBadRequest, "invalid_request", "请求参数无效")
|
||||
return
|
||||
}
|
||||
token, err := h.service.Login(input.Email, input.Password)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{"error": "invalid credentials"})
|
||||
abortWithError(c, http.StatusUnauthorized, "invalid_credentials", "邮箱或密码错误")
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"token": token})
|
||||
|
||||
Reference in New Issue
Block a user