Fixed lint + gofmt
the build failed Details

This commit is contained in:
konrad 2017-11-08 17:12:05 +01:00 committed by kolaente
parent b8738e9b52
commit ed1cd4be11
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
5 changed files with 17 additions and 12 deletions

View File

@ -7,6 +7,12 @@ import (
"fmt"
)
// UserLogin Object to recive user credentials in JSON format
type UserLogin struct {
Username string `json:"username" form:"username"`
Password string `json:"password" form:"password"`
}
func main() {
// Set Engine

View File

@ -3,9 +3,14 @@ package models
import (
"fmt"
"golang.org/x/crypto/bcrypt"
"git.mowie.cc/konrad/Library/routes"
)
// UserLogin Object to recive user credentials in JSON format
type UserLogin struct {
Username string `json:"username" form:"username"`
Password string `json:"password" form:"password"`
}
// User holds information about an user
type User struct {
ID int64 `xorm:"int(11) autoincr not null unique pk"`
@ -29,7 +34,7 @@ func HashPassword(password string) (string, error) {
}
// CheckUserCredentials checks user credentials
func CheckUserCredentials(u routes.UserLogin) (User, error) {
func CheckUserCredentials(u UserLogin) (User, error) {
// Check if the user exists
var user = User{Username: u.Username}

View File

@ -6,11 +6,11 @@ import (
)
// SetCORSHeader sets relevant CORS headers for Cross-Site-Requests to the api
func SetCORSHeader (c echo.Context) error {
func SetCORSHeader(c echo.Context) error {
res := c.Response()
res.Header().Set("Access-Control-Allow-Origin", "*")
res.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE")
res.Header().Set("Access-Control-Allow-Headers", "authorization,content-type")
res.Header().Set("Access-Control-Expose-Headers", "authorization,content-type")
return c.String(http.StatusOK, "")
}
}

View File

@ -8,15 +8,9 @@ import (
"time"
)
// User Login-Object to recive user credentials in JSON format
type UserLogin struct {
Username string `json:"username" form:"username"`
Password string `json:"password" form:"password"`
}
// Login is the login handler
func Login(c echo.Context) error {
u := new(UserLogin)
u := new(models.UserLogin)
if err := c.Bind(u); err != nil {
return c.JSON(http.StatusBadRequest, models.Message{"Please provide a username and password."})
}

View File

@ -1,10 +1,10 @@
package routes
import (
apiv1 "git.mowie.cc/konrad/Library/routes/api/v1"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
apiv1 "git.mowie.cc/konrad/Library/routes/api/v1"
"git.mowie.cc/konrad/Library/models"
)