Exemple #1
0
func Signout(ctx *Context) {
	if !ctx.User.IsAnonymous() {
		ctx.User.SetSession("")
		ctx.User = users.NewAnonymous()
	}
	http.SetCookie(ctx.Response, expiredCookie())
}
Exemple #2
0
func getUser(ctx dingo.Context) users.User {
	u, err := Users.BySession(GetCookieSession(ctx.Request))
	if err != nil {
		return users.NewAnonymous()
	}
	return u
}
Exemple #3
0
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()
}