Skip to content

Commit

Permalink
修改User API接口,避免密码泄漏
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyangkun committed Jan 28, 2024
1 parent 3c2dd32 commit 089ca14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ type User struct {
// GetAll 获取所有用户
func (user User) GetAll() ([]User, error) {
var users []User
err := db.Db.Find(&users).Error
err := db.Db.Select("username, email, nickname, user_img, signature").
Find(&users).Error
if gorm.IsRecordNotFoundError(err) {
err = nil
}
Expand Down
4 changes: 2 additions & 2 deletions routers/api_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func (a *ApiRouter) InitApiRouter(rootPath string, router *gin.Engine) {
userApiRouter := router.Group(rootPath)
{
userApiRouter.GET("/all_users", userHandler.GetAllUsers)
userApiRouter.PUT("/users", userHandler.UpdateUser)
userApiRouter.PUT("/users/pwd", userHandler.UpdateUserPwd)
userApiRouter.PUT("/users", middlewares.JWTAuth(), userHandler.UpdateUser)
userApiRouter.PUT("/users/pwd", middlewares.JWTAuth(), userHandler.UpdateUserPwd)
}

ArticleApiRouter := router.Group(rootPath)
Expand Down

0 comments on commit 089ca14

Please sign in to comment.