refactor: general architectural cleanup and bug fixes
This commit is contained in:
@@ -2,7 +2,6 @@ package handler
|
||||
|
||||
import (
|
||||
"mal/internal/domain"
|
||||
"mal/internal/server"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@@ -43,7 +42,11 @@ func (h *AuthHandler) HandleLogin(c *gin.Context) {
|
||||
}
|
||||
|
||||
c.SetCookie("session_id", session.ID, int(24*time.Hour.Seconds()), "/", "", false, true)
|
||||
c.Header("HX-Redirect", "/")
|
||||
if c.GetHeader("HX-Request") == "true" {
|
||||
c.Header("HX-Redirect", "/")
|
||||
c.Status(http.StatusOK)
|
||||
return
|
||||
}
|
||||
c.Redirect(http.StatusSeeOther, "/")
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,13 @@ package auth
|
||||
|
||||
import (
|
||||
"mal/internal/auth/handler"
|
||||
"mal/internal/auth/middleware"
|
||||
"mal/internal/auth/repository"
|
||||
"mal/internal/auth/service"
|
||||
"mal/internal/domain"
|
||||
"mal/internal/server"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/fx"
|
||||
)
|
||||
|
||||
@@ -14,6 +17,9 @@ var Module = fx.Options(
|
||||
repository.NewAuthRepository,
|
||||
service.NewAuthService,
|
||||
handler.NewAuthHandler,
|
||||
func(svc domain.AuthService) gin.HandlerFunc {
|
||||
return middleware.AuthMiddleware(svc)
|
||||
},
|
||||
),
|
||||
fx.Provide(
|
||||
server.AsRouteRegister(func(h *handler.AuthHandler) server.RouteRegister {
|
||||
|
||||
@@ -7,8 +7,6 @@ import (
|
||||
"mal/internal/db"
|
||||
"mal/internal/domain"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type authRepository struct {
|
||||
|
||||
Reference in New Issue
Block a user