Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Werner authored and Dennis Werner committed Jun 27, 2024
1 parent 0a6130a commit 3505d9f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
- name: Install templ
run: go install github.com/a-h/templ/cmd/templ@latest

- name: install templ runtime
run: go get github.com/a-h/templ/runtime

- name: Build templ
run: templ generate .

Expand Down
5 changes: 4 additions & 1 deletion web/api/v1/asset_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ func (a API) CreateAsset(c echo.Context) error {
// defer lock.Unlock()
s := c.Get("svc").(service.AssetSvc)
as := models.Asset{Id: uuid.New(), Name: "myPc", Type: models.AssetType{Name: "PC"}}
s.Create(&as)
err := s.Create(&as)
if err != nil {
return err
}

return c.JSON(http.StatusCreated, as)

Expand Down
18 changes: 8 additions & 10 deletions web/web.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package web

import (
"crypto/subtle"

"github.com/d4sw4r/blokhouse/internal/service"
api "github.com/d4sw4r/blokhouse/web/api/v1"
"github.com/d4sw4r/blokhouse/web/ui"
Expand Down Expand Up @@ -61,14 +59,14 @@ func (s Server) Start() error {
// return false
// }

func authMiddleware(username, password string, c echo.Context) (bool, error) {
// Be careful to use constant time comparison to prevent timing attacks
if subtle.ConstantTimeCompare([]byte(username), []byte("admin")) == 1 &&
subtle.ConstantTimeCompare([]byte(password), []byte("admin")) == 1 {
return true, nil
}
return false, nil
}
// func authMiddleware(username, password string, c echo.Context) (bool, error) {
// // Be careful to use constant time comparison to prevent timing attacks
// if subtle.ConstantTimeCompare([]byte(username), []byte("admin")) == 1 &&
// subtle.ConstantTimeCompare([]byte(password), []byte("admin")) == 1 {
// return true, nil
// }
// return false, nil
// }

func bindApp(svc service.AssetSvc) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
Expand Down

0 comments on commit 3505d9f

Please sign in to comment.