fix: remove logging from utils
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 44s
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 50s

This commit was merged in pull request #292.
This commit is contained in:
2024-12-04 21:23:19 +01:00
parent 9e8e595258
commit 5198487feb
8 changed files with 74 additions and 74 deletions

View File

@@ -1,6 +1,7 @@
package handler
import (
"me-fit/log"
"me-fit/service"
"me-fit/template/auth"
"me-fit/types"
@@ -29,16 +30,15 @@ func NewHandlerAuth(service service.AuthService, render *Render) HandlerAuth {
}
func (handler HandlerAuthImpl) Handle(router *http.ServeMux) {
// Don't use auth middleware for these routes, as it makes redirecting very difficult, if the mail is not yet verified
router.Handle("/auth/signin", handler.handleSignInPage())
router.Handle("/api/auth/signin", handler.handleSignIn())
router.Handle("/auth/signup", handler.handleSignUpPage())
router.Handle("/auth/verify", handler.handleSignUpVerifyPage())
router.Handle("/api/auth/verify-resend", handler.HandleVerifyResendComp())
router.Handle("/auth/verify-email", handler.HandleSignUpVerifyResponsePage())
router.Handle("/api/auth/signup", handler.handleSignUp())
router.Handle("/auth/signin", handler.handleSignInPage())
router.Handle("/api/auth/signin", handler.handleSignIn())
router.Handle("/api/auth/signout", handler.handleSignOut())
router.Handle("/auth/delete-account", handler.handleDeleteAccountPage())
@@ -105,7 +105,7 @@ func (handler HandlerAuthImpl) handleSignIn() http.HandlerFunc {
utils.TriggerToast(w, r, "error", "Invalid email or password")
http.Error(w, "Invalid email or password", http.StatusUnauthorized)
} else {
utils.LogError("Error signing in", err)
log.Error("Error signing in", err)
http.Error(w, "An error occurred", http.StatusInternalServerError)
}
return
@@ -305,7 +305,7 @@ func (handler HandlerAuthImpl) HandleVerifyResendComp() http.HandlerFunc {
_, err = w.Write([]byte("<p class=\"mt-8\">Verification email sent</p>"))
if err != nil {
utils.LogError("Could not write response", err)
log.Error("Could not write response", err)
}
}
}
@@ -370,7 +370,7 @@ func (handler HandlerAuthImpl) HandleForgotPasswordResponseComp() http.HandlerFu
pageUrl, err := url.Parse(r.Header.Get("HX-Current-URL"))
if err != nil {
utils.LogError("Could not get current URL", err)
log.Error("Could not get current URL", err)
utils.TriggerToast(w, r, "error", "Internal Server Error")
return
}

View File

@@ -1,11 +1,11 @@
package handler
import (
"me-fit/log"
"me-fit/service"
"me-fit/template"
"me-fit/template/auth"
"me-fit/types"
"me-fit/utils"
"net/http"
@@ -25,7 +25,7 @@ func NewRender(serverSettings *types.ServerSettings) *Render {
func (render *Render) Render(r *http.Request, w http.ResponseWriter, comp templ.Component) {
err := comp.Render(r.Context(), w)
if err != nil {
utils.LogError("Failed to render layout", err)
log.Error("Failed to render layout", err)
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
}
}