Re-migrate code
This commit is contained in:
@@ -125,7 +125,7 @@ func (s *AuthService) ValidateUser(username, password string) (models.User, erro
|
||||
var user models.User
|
||||
err := database.DB.Where("username = ?", username).First(&user).Error
|
||||
if err != nil {
|
||||
return models.User{}, errors.New("用户名或密码错误")
|
||||
return models.User{}, errors.New("用户名或密码不正确")
|
||||
}
|
||||
return user, nil
|
||||
}
|
||||
@@ -149,6 +149,9 @@ func (c *AuthController) Login(ctx *gin.Context) {
|
||||
}
|
||||
```
|
||||
|
||||
- Use `ErrorResponse` for API errors so messages are user-friendly and consistent.
|
||||
- Do not leak raw DB/stack errors to clients; log internal details and return safe messages.
|
||||
|
||||
### Response Format
|
||||
**Success response**:
|
||||
```json
|
||||
@@ -158,6 +161,8 @@ func (c *AuthController) Login(ctx *gin.Context) {
|
||||
}
|
||||
```
|
||||
|
||||
Some endpoints also return Node-compatible top-level keys (e.g. `serial`, `serials`, `pagination`) to preserve frontend compatibility.
|
||||
|
||||
**Error response**:
|
||||
```json
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user