func (this *SsoController) Logout() { sig := this.Ctx.Input.Param(":sig") if sig == "" { this.ServeErrJson("sig is blank") return } s := uic.ReadSessionBySig(sig) if s != nil { uic.RemoveSessionByUid(s.Uid) } this.ServeOKJson() }
func (this *SsoController) User() { sig := this.Ctx.Input.Param(":sig") if sig == "" { this.NotFound("sig is blank") return } s := uic.ReadSessionBySig(sig) if s == nil { this.NotFound("no such sig") return } u := uic.ReadUserById(s.Uid) if u == nil { this.NotFound("no such user") return } this.Data["json"] = map[string]interface{}{ "user": u, } this.ServeJson() }
"github.com/astaxie/beego/context" "github.com/open-falcon/fe/g" "github.com/open-falcon/fe/model/uic" "github.com/open-falcon/fe/utils" "strconv" "time" ) var FilterLoginUser = func(ctx *context.Context) { cookieSig := ctx.GetCookie("sig") if cookieSig == "" { ctx.Redirect(302, "/auth/login?callback="+ctx.Request.URL.String()) return } sessionObj := uic.ReadSessionBySig(cookieSig) if sessionObj == nil || int64(sessionObj.Expired) < time.Now().Unix() { ctx.Redirect(302, "/auth/login?callback="+ctx.Request.URL.String()) return } u := uic.ReadUserById(sessionObj.Uid) if u == nil { ctx.Redirect(302, "/auth/login?callback="+ctx.Request.URL.String()) return } ctx.Input.SetData("CurrentUser", u) } var FilterTargetUser = func(ctx *context.Context) {