func (u *User) UpdatePassword(password string) {
	hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
	if err != nil {
		log.Fatalf("Couldn't generate hashed password: %v\n", err)
	}

	u.Password = string(hash)

	stmt := `UPDATE users SET name = ?, password = ? WHERE id = ?`
	db.Exec(stmt, u.Name, u.Password, u.ID)
}
// UpdatePassword saves the new password (hash) into the existing user's entry.
// This method hashes the password properly.
UpdatePassword saves the new password (hash) into the existing user's entry.
This method hashes the password properly.
// UpdatePassword saves the new password ( hash ) into the existing user ' s entry . // This method hashes the password properly .
func (u *User) UpdatePassword(password string) {
	hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
	if err != nil {
		log.Fatalf("Couldn't generate hashed password: %v\n", err)
	}
	u.Password = string(hash)
	stmt := `UPDATE users SET name = ?, password = ? WHERE id = ?`
	db.Exec(stmt, u.Name, u.Password, u.ID)
}
func ( u * User ) UpdatePassword ( password string ) { hash , err := bcrypt . GenerateFromPassword ( [ ] byte ( password ) , bcrypt . DefaultCost ) if err != nil { log . Fatalf ( " \n " , err ) } u . Password = string ( hash ) stmt := `UPDATE users SET name = ?, password = ? WHERE id = ?` db . Exec ( stmt , u . Name , u . Password , u . ID ) }
UpdatePassword saves the new password (hash) into the existing user's entry.
UpdatePassword saves the new password ( hash ) into the existing user ' s entry .