2023-09-04 11:13:21 +02:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
|
|
import (
|
2023-09-11 08:08:24 +02:00
|
|
|
"gitlab.com/pactual1/backend/middlewares"
|
2023-09-11 08:08:24 +02:00
|
|
|
|
2023-09-11 08:08:24 +02:00
|
|
|
"gitlab.com/pactual1/backend/shared"
|
2023-09-11 08:08:24 +02:00
|
|
|
|
2023-09-04 11:13:21 +02:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type AuthController struct{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (this 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 {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
c.JSON(200, token)
|
|
|
|
|
}
|