Setup boilerplate gorm , and admin part
This commit is contained in:
29
controllers/AuthController.go
Normal file
29
controllers/AuthController.go
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Created by VoidArtanis on 11/2/2017
|
||||
*/
|
||||
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/VoidArtanis/go-rest-boilerplate/middlewares"
|
||||
"github.com/VoidArtanis/go-rest-boilerplate/shared"
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user