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 {
 | 
			
		||||
	Username string `json:"username" binding:"required"`
 | 
			
		||||
	Password string `json:"password" binding:"required"`
 | 
			
		||||
	Password string `json:"password"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Login(c *gin.Context) {
 | 
			
		||||
| 
						 | 
				
			
			@ -75,7 +75,9 @@ func UpdateCurrent(c *gin.Context) {
 | 
			
		|||
	}
 | 
			
		||||
	user := c.MustGet("user").(*model.User)
 | 
			
		||||
	user.Username = req.Username
 | 
			
		||||
	user.Password = req.Password
 | 
			
		||||
	if req.Password != "" {
 | 
			
		||||
		user.Password = req.Password
 | 
			
		||||
	}
 | 
			
		||||
	if err := db.UpdateUser(user); err != nil {
 | 
			
		||||
		common.ErrorResp(c, err, 500)
 | 
			
		||||
	} else {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,8 +22,8 @@ func Init(r *gin.Engine) {
 | 
			
		|||
	auth := api.Group("", middlewares.Auth)
 | 
			
		||||
 | 
			
		||||
	api.POST("/auth/login", handles.Login)
 | 
			
		||||
	auth.GET("/profile", handles.CurrentUser)
 | 
			
		||||
	auth.POST("/profile/update", handles.UpdateCurrent)
 | 
			
		||||
	auth.GET("/me", handles.CurrentUser)
 | 
			
		||||
	auth.POST("/me/update", handles.UpdateCurrent)
 | 
			
		||||
 | 
			
		||||
	// no need auth
 | 
			
		||||
	public := api.Group("/public")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue