Example #1
0
func (h *handler) makeSession(user *auth.User) error {
	if user == nil {
		return &base.HTTPError{http.StatusUnauthorized, "Invalid login"}
	}
	h.user = user
	auth := h.context.auth
	session, err := auth.CreateSession(user.Name, kDefaultSessionTTL)
	if err != nil {
		return err
	}
	http.SetCookie(h.response, auth.MakeSessionCookie(session))
	return h.respondWithSessionInfo()
}
Example #2
0
func (h *handler) makeSession(user auth.User) error {
	if user == nil {
		return base.HTTPErrorf(http.StatusUnauthorized, "Invalid login")
	}
	h.user = user
	auth := h.db.Authenticator()
	session, err := auth.CreateSession(user.Name(), kDefaultSessionTTL)
	if err != nil {
		return err
	}
	cookie := auth.MakeSessionCookie(session)
	cookie.Path = "/" + h.db.Name + "/"
	http.SetCookie(h.response, cookie)
	return h.respondWithSessionInfo()
}