func (raf *RequireAdminFilter) OnActionExecuting(ctx *goku.HttpContext) (ar goku.ActionResulter, err error) { ar, err = raf.RequireLoginFilter.OnActionExecuting(ctx) if ar != nil || err != nil { return } user := ctx.Data["user"].(*models.User) if !user.IsAdmin() { if ctx.IsAjax() { ar = ctx.Json(map[string]interface{}{ "success": false, "needLogin": false, "errors": "没有权限", }) } else { // ctx.ViewData["errorMsg"] = "没有权限" // ar = ctx.Render("error", nil) ar = ctx.Raw("没有权限") } } return }
func (tf *AjaxFilter) OnActionExecuting(ctx *goku.HttpContext) (ar goku.ActionResulter, err error) { if !ctx.IsAjax() { return ctx.Raw("Not AJAX"), nil } return nil, nil }