diff --git a/Makefile b/Makefile index 827448c..e734ec9 100644 --- a/Makefile +++ b/Makefile @@ -29,5 +29,5 @@ run: go run main.go .PHONY: test -run: +test: go test ./... \ No newline at end of file diff --git a/container/container_test.go b/container/container_test.go index ec1bce7..029ac46 100644 --- a/container/container_test.go +++ b/container/container_test.go @@ -54,7 +54,6 @@ func TestMain(m *testing.M) { } func TestNewContainer(t *testing.T) { - c := NewContainer() assert.NotNil(t, c.Web) assert.NotNil(t, c.Config) assert.NotNil(t, c.Cache) diff --git a/middleware/auth.go b/middleware/auth.go index 12c46e3..7bf8cf3 100644 --- a/middleware/auth.go +++ b/middleware/auth.go @@ -3,7 +3,7 @@ package middleware import ( "net/http" - "goweb/auth" + "goweb/container" "goweb/context" "goweb/ent" "goweb/msg" @@ -11,14 +11,14 @@ import ( "github.com/labstack/echo/v4" ) -func LoadAuthenticatedUser(authClient *auth.Client) echo.MiddlewareFunc { +func LoadAuthenticatedUser(authClient *container.AuthClient) echo.MiddlewareFunc { return func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { u, err := authClient.GetAuthenticatedUser(c) switch err.(type) { case *ent.NotFoundError: c.Logger().Debug("auth user not found") - case auth.NotAuthenticatedError: + case container.NotAuthenticatedError: case nil: c.Set(context.AuthenticatedUserKey, u) c.Logger().Info("auth user loaded in to context: %d", u.ID) @@ -31,7 +31,7 @@ func LoadAuthenticatedUser(authClient *auth.Client) echo.MiddlewareFunc { } } -func LoadValidPasswordToken(authClient *auth.Client) echo.MiddlewareFunc { +func LoadValidPasswordToken(authClient *container.AuthClient) echo.MiddlewareFunc { return func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { var usr *ent.User @@ -46,7 +46,7 @@ func LoadValidPasswordToken(authClient *auth.Client) echo.MiddlewareFunc { switch err.(type) { case nil: - case auth.InvalidTokenError: + case container.InvalidTokenError: msg.Warning(c, "The link is either invalid or has expired. Please request a new one.") return c.Redirect(http.StatusFound, c.Echo().Reverse("forgot_password")) default: