示例#1
0
文件: main.go 项目: everfore/fservice
func CheckLogin(ctx *context.Context) {
	if ctx.Request.RequestURI != "/login" {
		sess, err := models.GlobalSessions.SessionStart(ctx.ResponseWriter, ctx.Request)
		if err != nil || sess == nil {
			ctx.Abort(401, "session nil")
		}
		sessioner := sess.Get("gosessionkey")
		beego.Debug("session:", sess)
		beego.Debug("check login gosessionkey:", sessioner)
		if fmt.Sprintf("%v", sessioner) != "beego1234" {
			ctx.Redirect(401, "/login")
		}
	}
}