package handler

import (
	"net/http"

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

type AuthHandler struct{}

func NewAuthHandler() *AuthHandler { return &AuthHandler{} }

func (h *AuthHandler) Check(c *gin.Context) {
	account, exists := c.Get("account")
	if !exists || account == "" {
		c.JSON(http.StatusOK, gin.H{"success": true, "logged_in": false})
		return
	}
	username, _ := c.Get("username")
	email, _ := c.Get("email")
	c.JSON(http.StatusOK, gin.H{
		"success":   true,
		"logged_in": true,
		"user": gin.H{
			"account":  account,
			"username": username,
			"email":    email,
		},
	})
}
