Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasIdentity ¶
func HasIdentity(v ViewerContext) bool
HasIdentity returns a boolean indicating if the viewer has an identity
func IsOmniscient ¶
func IsOmniscient(v ViewerContext) bool
IsOmniscient is a convenient method indicating that
func NewRequestWithContext ¶
func NewRequestWithContext(r *http.Request, viewer ViewerContext) *http.Request
Types ¶
type LoggedInEntity ¶
type LoggedInEntity interface {
GetID() string
}
LoggedInEntity returns the identity of the logged in viewer
type LoggedOutViewerContext ¶
type LoggedOutViewerContext struct{}
LoggedOutViewerContext struct is the default ViewerContext provided by the ent framework It represents a viewer with no logged in identity
func (LoggedOutViewerContext) GetViewer ¶
func (LoggedOutViewerContext) GetViewer() LoggedInEntity
GetViewer returns the Logged in Viewer. For the LoggedOutViewerContext, this is nil
func (LoggedOutViewerContext) GetViewerID ¶
func (LoggedOutViewerContext) GetViewerID() string
GetViewerID returns the ID of the logged in viewer
type OmniscientViewerContext ¶
type OmniscientViewerContext interface {
IsOmniscient() bool
}
TODO kill this. This isn't generic enough Returns a boolean indicating if this user can see everything Needed for places without actual privacy checks or for admin tools or other such things rename to CanSeeAllContent()? OverridePrivacyChecks()? Or just have a second interface that's not necessary to mandate and do a typecheck on that ViewerContextWhichOverridesPrivacy
type ViewerContext ¶
type ViewerContext interface { // GetViewer returns the identity of the logged in viewer. should return nil if logged out // TODO this should probably be (LoggedInEntity, error). hmm GetViewer() LoggedInEntity // GetViewerID returns the id of the logged in viewer. // It's provided as a convenience method and in case GetViewer() is expensive to compute GetViewerID() string }
ViewerContext interface is to be implemented by clients to indicate who's trying to view the ent
func ForContext ¶
func ForContext(ctx context.Context) (ViewerContext, error)
func LoggedOutViewer ¶
func LoggedOutViewer() ViewerContext
LoggedOutViewer returns an instance of LoggedOutViewerContext as the default Viewer in the ent framework