multitenantStack/controllers/baseAPI.go

30 lines
694 B
Go
Raw Normal View History

2018-11-07 10:10:51 +00:00
package controllers
// BaseController operations for APIs
type BaseAPIController struct {
BaseController
}
func (this *BaseAPIController) Prepare() {
2018-11-07 15:27:39 +00:00
/*
//Lo que quieras hacer en todos los controladores
// O puede ser leído de una cabecera HEADER!!
tokenString := this.Ctx.Request.Header.Get("X-JWTtoken")
et := jwtbeego.EasyToken{}
valid, issuer, _ := et.ValidateToken(tokenString)
if !valid {
this.Ctx.Output.SetStatus(401)
this.ServeJsonError("Invalid Token")
}
/*
userSession := this.GetSession("username")
2018-11-07 10:10:51 +00:00
2018-11-07 15:27:39 +00:00
if userSession == nil || userSession != issuer {
this.Ctx.Output.SetStatus(401)
this.ServeJsonError("Invalid Session")
}
*/
//return
2018-11-07 10:10:51 +00:00
}