1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-06-27 16:36:00 +00:00

Refactor packages to have more idiomatic code base

This commit is contained in:
Frédéric Guillot 2018-01-02 22:04:48 -08:00
parent c39f2e1a8d
commit 320d1b0167
109 changed files with 449 additions and 402 deletions

34
ui/form/auth.go Normal file
View file

@ -0,0 +1,34 @@
// Copyright 2017 Frédéric Guillot. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package form
import (
"net/http"
"github.com/miniflux/miniflux/errors"
)
// AuthForm represents the authentication form.
type AuthForm struct {
Username string
Password string
}
// Validate makes sure the form values are valid.
func (a AuthForm) Validate() error {
if a.Username == "" || a.Password == "" {
return errors.NewLocalizedError("All fields are mandatory.")
}
return nil
}
// NewAuthForm returns a new AuthForm.
func NewAuthForm(r *http.Request) *AuthForm {
return &AuthForm{
Username: r.FormValue("username"),
Password: r.FormValue("password"),
}
}