viewer

package
v0.0.0-...-98a7958 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package viewer enables setting and reading the current user contexts

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, v Viewer) context.Context

NewContext creates a new context with the current user information.

Types

type Viewer

type Viewer struct {
	User    *kolide.User
	Session *kolide.Session
}

Viewer holds information about the current user and the user's session

func FromContext

func FromContext(ctx context.Context) (Viewer, bool)

FromContext returns the current user information if present.

func (Viewer) CanPerformActions

func (v Viewer) CanPerformActions() bool

CanPerformActions returns a bool indicating the current user's ability to perform the most basic actions on the site

func (Viewer) CanPerformAdminActions

func (v Viewer) CanPerformAdminActions() bool

CanPerformAdminActions indicates whether or not the current user can perform administrative actions.

func (Viewer) CanPerformPasswordReset

func (v Viewer) CanPerformPasswordReset() bool

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

func (v Viewer) CanPerformReadActionOnUser(uid uint) bool

CanPerformReadActionOnUser returns a bool indicating the current user's ability to perform read actions on the given user

func (Viewer) CanPerformWriteActionOnUser

func (v Viewer) CanPerformWriteActionOnUser(uid uint) bool

CanPerformWriteActionOnUser returns a bool indicating the current user's ability to perform write actions on the given user

func (Viewer) FullName

func (v Viewer) FullName() string

FullName is a helper that enables quick access to the full name of the current user.

func (Viewer) IsLoggedIn

func (v Viewer) IsLoggedIn() bool

IsLoggedIn determines whether or not the current VC is attached to a user account

func (Viewer) IsUserID

func (v Viewer) IsUserID(id uint) bool

IsUserID returns true if the given user id the same as the user which is represented by this ViewerContext

func (Viewer) SessionID

func (v Viewer) SessionID() uint

SessionID returns the current user's session ID

func (Viewer) UserID

func (v Viewer) UserID() uint

UserID is a helper that enables quick access to the user ID of the current user.

func (Viewer) Username

func (v Viewer) Username() string

Username is a helper that enables quick access to the username of the current user.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL