sessions

package
v0.0.0-...-f03aceb Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlashSuccess string = "success"
	FlashInfo    string = "info"
	FlashWarning string = "warning"
	FlashDanger  string = "danger"
)

Flash is used to hold flash information for use in templates.

View Source
const (
	TokenName = "csrf_token"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type SessionFlash

type SessionFlash struct {
	Type     string
	Message  string
	Closable bool
}

Flash is used to hold flash information for use in templates.

type SessionManager

type SessionManager struct {
	*scs.SessionManager
}

func SetupSession

func SetupSession(config *config.Config) *SessionManager

func (*SessionManager) AddFlash

func (session *SessionManager) AddFlash(ctx context.Context, value SessionFlash, vars ...string)

AddFlash adds a flash message to the session. An optional flash key can be provided, otherwise "_flash" is used by default.

func (*SessionManager) Flashes

func (session *SessionManager) Flashes(ctx context.Context, vars ...string) []SessionFlash

Flashes retrieves flash messages from the session. An optional flash key can be provided, otherwise "_flash" is used by default.

func (*SessionManager) GenerateCSRF

func (session *SessionManager) GenerateCSRF(ctx context.Context)

func (*SessionManager) GetCSRF

func (session *SessionManager) GetCSRF(ctx context.Context) string

func (*SessionManager) ValidateCSRF

func (session *SessionManager) ValidateCSRF(ctx context.Context, inputToken string) bool

Jump to

Keyboard shortcuts

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