package controllers

import (
	"log"
	"net/http"

	"gitlab.com/pactual1/backend/middlewares"

	"gitlab.com/pactual1/backend/shared"

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

type AuthController struct{}

func (AuthController) HandleLogin(c *gin.Context) {
	userId := "123"
	username := "Beast"
	roles := []string{shared.RoleAdmin, shared.RoleProUser}

	// do user auth here

	//issue token
	token, err := middlewares.GenerateToken([]byte(middlewares.SigningKey), userId, username, roles)
	if err != nil {
		log.Printf("Unable to generate token %v", err)
		c.JSON(http.StatusInternalServerError, err)

	}
	c.JSON(200, token)
}
