32 lines
562 B
Go
32 lines
562 B
Go
/**
|
|
* Created by VoidArtanis on 11/2/2017
|
|
*/
|
|
|
|
package controllers
|
|
|
|
import (
|
|
"gitlab.com/pactual1/backend/config/middlewares"
|
|
|
|
"gitlab.com/pactual1/backend/config/shared"
|
|
|
|
"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)
|
|
}
|