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() }
) 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) { userName := ctx.Input.Query("name") if userName == "" { ctx.ResponseWriter.WriteHeader(403) ctx.ResponseWriter.Write([]byte("Name is necessary")) return }