webauthn.go 739 B

12345678910111213141516171819202122232425262728293031
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package form // import "miniflux.app/v2/internal/ui/form"
  4. import (
  5. "net/http"
  6. "strings"
  7. "miniflux.app/v2/internal/locale"
  8. )
  9. // WebauthnForm represents a credential rename form in the UI
  10. type WebauthnForm struct {
  11. Name string
  12. }
  13. // Validate makes sure the form values are valid.
  14. func (f *WebauthnForm) Validate() *locale.LocalizedError {
  15. if f.Name == "" {
  16. return locale.NewLocalizedError("error.fields_mandatory")
  17. }
  18. return nil
  19. }
  20. // NewWebauthnForm returns a new WebnauthnForm.
  21. func NewWebauthnForm(r *http.Request) *WebauthnForm {
  22. return &WebauthnForm{
  23. Name: strings.TrimSpace(r.FormValue("name")),
  24. }
  25. }