Fixed lint + gofmt
the build failed
Details
the build failed
Details
This commit is contained in:
parent
b8738e9b52
commit
ed1cd4be11
6
main.go
6
main.go
|
@ -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
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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, "")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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."})
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue