Exemple #1
0
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()
}
Exemple #2
0
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()
}
Exemple #3
0
import (
	"github.com/astaxie/beego/context"
	"github.com/gaochao1/fe/model/uic"
	"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) {