func Signout(ctx *Context) { if !ctx.User.IsAnonymous() { ctx.User.SetSession("") ctx.User = users.NewAnonymous() } http.SetCookie(ctx.Response, expiredCookie()) }
func getUser(ctx dingo.Context) users.User { u, err := Users.BySession(GetCookieSession(ctx.Request)) if err != nil { return users.NewAnonymous() } return u }
func getExpireUser(ctx dingo.Context) users.User { if cookie, key, ok := UpdatedExpireCookie(ctx.Request); ok { if u, err := Users.BySession(key); err == nil { http.SetCookie(ctx.Response, cookie) return u } /*} else if cookie != nil { http.SetCookie(ctx.Response, cookie)*/ } return users.NewAnonymous() }