blob: d1a9055b818b4a15843b67f6e878211c619801b9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package form // import "miniflux.app/v2/internal/ui/form"
import (
"net/http"
"strings"
"miniflux.app/v2/internal/locale"
)
// AuthForm represents the authentication form.
type AuthForm struct {
Username string
Password string
}
// Validate makes sure the form values are valid.
func (a AuthForm) Validate() *locale.LocalizedError {
if a.Username == "" || a.Password == "" {
return locale.NewLocalizedError("error.fields_mandatory")
}
return nil
}
// NewAuthForm returns a new AuthForm.
func NewAuthForm(r *http.Request) *AuthForm {
return &AuthForm{
Username: strings.TrimSpace(r.FormValue("username")),
Password: strings.TrimSpace(r.FormValue("password")),
}
}
|