aboutsummaryrefslogtreecommitdiffstats
path: root/backend/internal/api/handlers/auth_handlers.go
blob: 18d8a1a198857de5890b378ef61083a1990527dd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package handlers

import (
	"finance/backend/internal/api/auth"
	"finance/backend/internal/config"

	"github.com/gin-gonic/gin"
)

// AuthHandler handles authentication-related operations
type AuthHandler struct {
	config *config.Config
}

// NewAuthHandler creates and returns a new AuthHandler instance
func NewAuthHandler(cfg *config.Config) *AuthHandler {
	return &AuthHandler{
		config: cfg,
	}
}

// Register handles user registration
func (h *AuthHandler) Register(c *gin.Context) {
	// Delegate to the existing auth.Signup handler
	auth.Signup(h.config)(c)
}

// Login handles user authentication
func (h *AuthHandler) Login(c *gin.Context) {
	// Delegate to the existing auth.Login handler
	auth.Login(h.config)(c)
}

// JWTAuth middleware validates JWT tokens
func (h *AuthHandler) JWTAuth(c *gin.Context) {
	// Delegate to the existing auth.AuthMiddleware
	auth.AuthMiddleware(h.config)(c)
}