user

package
v0.0.0-...-cda7898 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package user is used to define the system's user structure with user.User and extracting user's details in a request's context using ExtractRequestUser.

Index

Constants

View Source
const (
	// ContextUserKey is the context key used to get and set the user's data in the context.
	ContextUserKey = "User"

	// ParamUserID is the name of the user id param in URL.
	ParamUserID = "id"

	// ParamApproverID is the name of the approver id param in the URL.
	ParamApproverID = "approverID"

	// ParamRequestContent is the name of the partial user name param in URL.
	ParamRequestContent = "content"

	// ParamSearchType is the name of the flag that determines which search to execute.
	ParamSearchType = "searchBy"

	// ExternalUserSource is the value of the source field of user that indicated that the user is external
	ExternalUserSource = "external"

	// InternalUserSource is the value of the source field of user that indicated that the user is internal
	InternalUserSource = "internal"

	// ConfigBucketPostfix is the name of the environment variable containing the postfix for the bucket.
	ConfigBucketPostfix = "bucket_postfix"

	// TransactionUserLabel is the label of the custom transaction field : user.
	TransactionUserLabel = "user"

	// HeaderDestionation is the header used to get and set the external destination.
	HeaderDestionation = "destination"

	// ConfigTomcalDest is the name of the environment variable containing the tomcal dest name.
	ConfigTomcalDest = "tomcal_dest_value"

	// ConfigCtsDest is the name of the environment variable containing the cts dest name.
	ConfigCtsDest = "cts_dest_value"

	ConfigCTSSuffix = "cts_suffix"
)
View Source
const (
	// SearchByName is an enum key for searching by name
	SearchByName searchByEnum = "SearchByName"

	// FindByMail is an enum key for finding by mail
	FindByMail searchByEnum = "FindByMail"

	// FindByT is an enum key for finding by user T
	FindByT searchByEnum = "FindByT"
)

Variables

This section is empty.

Functions

func IsExternalUser

func IsExternalUser(userID string) bool

IsExternalUser gets a userID and returns true if user is from an external source. Otherwise, returns false. Currently just and all of the external users don't have a valid mongoID .

func SetApmUser

func SetApmUser(ctx *gin.Context, user User)

SetApmUser adds a user to the current apm transaction.

Types

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router is a structure that handles users requests.

func NewRouter

func NewRouter(
	userConn *grpcPoolTypes.ConnPool,
	logger *logrus.Logger,
) *Router

NewRouter creates a new Router, and initializes clients of User Service

with the given connections. If logger is non-nil then it will

be set as-is, otherwise logger would default to logrus.New().

func (*Router) FindByMail

func (r *Router) FindByMail(c *gin.Context)

FindByMail is the request handler for GET /users with flag FindByMailFlag

func (*Router) FindByUserT

func (r *Router) FindByUserT(c *gin.Context)

FindByUserT is the request handler for GET /users with flag FindByTFlag

func (*Router) GetUserByID

func (r *Router) GetUserByID(c *gin.Context)

GetUserByID is the request handler for GET /users/:id

func (*Router) SearchByName

func (r *Router) SearchByName(c *gin.Context)

SearchByName is the request handler for GET /users

func (*Router) SearchByRouter

func (r *Router) SearchByRouter(c *gin.Context)

SearchByRouter is the search by request router for GET /users

func (*Router) Setup

func (r *Router) Setup(rg *gin.RouterGroup)

Setup sets up r and initializes its routes under rg.

type User

type User struct {
	ID          string `json:"id"`
	FirstName   string `json:"firstname"`
	LastName    string `json:"lastname"`
	Source      string `json:"source"`
	Bucket      string `json:"bucket"`
	DisplayName string `json:"displayName"`
	CurrentUnit string `json:"currentUnit"`
	Rank        string `json:"rank"`
	Job         string `json:"job"`
}

User is a structure of an authenticated user.

func ExtractRequestUser

func ExtractRequestUser(ctx context.Context) *User

ExtractRequestUser gets a context.Context and extracts the user's details from c.

Jump to

Keyboard shortcuts

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