func (d Dao) UpdatePassword(ctx context.Context, u User, newP string) error {
	if _, err := d.Login(ctx, u); err != nil {
		if errors.Is(err, ErrIncorrectLogin) {
			return ErrIncorrectLogin
		}
		return fmt.Errorf("checking password: %w", err)
	}
	if err := validatePassword(newP); err != nil {
		return err
	}
	u.password = newP
	hashedPassword, err := u.hashPassword()
	if err != nil {
		return err
	}
	q := db.NewExecFunction("user_update_password", u.Username, hashedPassword)
	if err := d.db.Exec(ctx, q); err != nil {
		return fmt.Errorf("updating user password: %w", err)
	}
	return nil
}
// UpdatePassword sets the password of a user.
UpdatePassword sets the password of a user.
// UpdatePassword sets the password of a user .
func (d Dao) UpdatePassword(ctx context.Context, u User, newP string) error {
	if _, err := d.Login(ctx, u); err != nil {
		if errors.Is(err, ErrIncorrectLogin) {
			return ErrIncorrectLogin
		}
		return fmt.Errorf("checking password: %w", err)
	}
	if err := validatePassword(newP); err != nil {
		return err
	}
	u.password = newP
	hashedPassword, err := u.hashPassword()
	if err != nil {
		return err
	}
	q := db.NewExecFunction("user_update_password", u.Username, hashedPassword)
	if err := d.db.Exec(ctx, q); err != nil {
		return fmt.Errorf("updating user password: %w", err)
	}
	return nil
}
func ( d Dao ) UpdatePassword ( ctx context . Context , u User , newP string ) error { if _ , err := d . Login ( ctx , u ) ; err != nil { if errors . Is ( err , ErrIncorrectLogin ) { return ErrIncorrectLogin } return fmt . Errorf ( " " , err ) } if err := validatePassword ( newP ) ; err != nil { return err } u . password = newP hashedPassword , err := u . hashPassword ( ) if err != nil { return err } q := db . NewExecFunction ( " " , u . Username , hashedPassword ) if err := d . db . Exec ( ctx , q ) ; err != nil { return fmt . Errorf ( " " , err ) } return nil }
UpdatePassword sets the password of a user.
UpdatePassword sets the password of a user .