mirror of https://github.com/Xhofe/alist
chore: password can be empty when update me
parent
4f3129ec28
commit
9d92834ee3
|
@ -18,7 +18,7 @@ var (
|
||||||
|
|
||||||
type LoginReq struct {
|
type LoginReq struct {
|
||||||
Username string `json:"username" binding:"required"`
|
Username string `json:"username" binding:"required"`
|
||||||
Password string `json:"password" binding:"required"`
|
Password string `json:"password"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func Login(c *gin.Context) {
|
func Login(c *gin.Context) {
|
||||||
|
@ -75,7 +75,9 @@ func UpdateCurrent(c *gin.Context) {
|
||||||
}
|
}
|
||||||
user := c.MustGet("user").(*model.User)
|
user := c.MustGet("user").(*model.User)
|
||||||
user.Username = req.Username
|
user.Username = req.Username
|
||||||
|
if req.Password != "" {
|
||||||
user.Password = req.Password
|
user.Password = req.Password
|
||||||
|
}
|
||||||
if err := db.UpdateUser(user); err != nil {
|
if err := db.UpdateUser(user); err != nil {
|
||||||
common.ErrorResp(c, err, 500)
|
common.ErrorResp(c, err, 500)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -22,8 +22,8 @@ func Init(r *gin.Engine) {
|
||||||
auth := api.Group("", middlewares.Auth)
|
auth := api.Group("", middlewares.Auth)
|
||||||
|
|
||||||
api.POST("/auth/login", handles.Login)
|
api.POST("/auth/login", handles.Login)
|
||||||
auth.GET("/profile", handles.CurrentUser)
|
auth.GET("/me", handles.CurrentUser)
|
||||||
auth.POST("/profile/update", handles.UpdateCurrent)
|
auth.POST("/me/update", handles.UpdateCurrent)
|
||||||
|
|
||||||
// no need auth
|
// no need auth
|
||||||
public := api.Group("/public")
|
public := api.Group("/public")
|
||||||
|
|
Loading…
Reference in New Issue