Documentation
¶
Overview ¶
Package viewer enables setting and reading the current user contexts
Index ¶
- func NewContext(ctx context.Context, v Viewer) context.Context
- type Viewer
- func (v Viewer) CanPerformActions() bool
- func (v Viewer) CanPerformAdminActions() bool
- func (v Viewer) CanPerformPasswordReset() bool
- func (v Viewer) CanPerformReadActionOnUser(uid uint) bool
- func (v Viewer) CanPerformWriteActionOnUser(uid uint) bool
- func (v Viewer) FullName() string
- func (v Viewer) IsLoggedIn() bool
- func (v Viewer) IsUserID(id uint) bool
- func (v Viewer) SessionID() uint
- func (v Viewer) UserID() uint
- func (v Viewer) Username() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Viewer ¶
Viewer holds information about the current user and the user's session
func FromContext ¶
FromContext returns the current user information if present.
func (Viewer) CanPerformActions ¶
CanPerformActions returns a bool indicating the current user's ability to perform the most basic actions on the site
func (Viewer) CanPerformAdminActions ¶
CanPerformAdminActions indicates whether or not the current user can perform administrative actions.
func (Viewer) CanPerformPasswordReset ¶
CanPerformPasswordReset returns a bool indicating the current user's ability to perform a password reset (in the case they have been required by the admin).
func (Viewer) CanPerformReadActionOnUser ¶
CanPerformReadActionOnUser returns a bool indicating the current user's ability to perform read actions on the given user
func (Viewer) CanPerformWriteActionOnUser ¶
CanPerformWriteActionOnUser returns a bool indicating the current user's ability to perform write actions on the given user
func (Viewer) FullName ¶
FullName is a helper that enables quick access to the full name of the current user.
func (Viewer) IsLoggedIn ¶
IsLoggedIn determines whether or not the current VC is attached to a user account
func (Viewer) IsUserID ¶
IsUserID returns true if the given user id the same as the user which is represented by this ViewerContext