Files
futur-web-app/server/internal/handlers/login_handler.go
2026-01-24 15:59:05 +02:00

28 lines
649 B
Go

package handlers
import (
"net/http"
"github.com/gin-gonic/gin"
)
type LoginHandler struct{}
func NewLoginHandler() *LoginHandler {
return &LoginHandler{}
}
func (lh *LoginHandler) Login(c *gin.Context) {
email := c.PostForm("email")
password := c.PostForm("password")
// Simple check, replace with real auth
if email == "test@example.com" && password == "password" {
c.Header("Content-Type", "text/html")
c.String(http.StatusOK, "<p>Login successful! <a href='/dashboard'>Go to Dashboard</a></p>")
} else {
c.Header("Content-Type", "text/html")
c.String(http.StatusUnauthorized, "<p>Invalid credentials. Try again.</p>")
}
}