session

package
v0.0.0-...-a3d754a Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2015 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package session provides functionality to manage user sessions and temporary storages. The web handlers will mainly interact with this package to retrieve information. If the required information is not found within the session storage, the database backend is being queried.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

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

Controller provides functionality to handle sessions and cached values as well as retrieval of data

func SetupSessionController

func SetupSessionController(conf *misc.Configuration, db database.Connection, mailer *mail.Controller) (*Controller, error)

SetupSessionController prepares the controller's session store and sets a default session lifespan

func (*Controller) Authenticate

func (controller *Controller) Authenticate(w http.ResponseWriter, r *http.Request, username string, password string) error

Authenticate validates the given username and password against the database and creates a new session with timestamp if successful

func (*Controller) CalculateFuelShoppingList

func (controller *Controller) CalculateFuelShoppingList(poses []*models.POS) (*models.FuelShoppingList, error)

func (*Controller) CheckEmailReminder

func (controller *Controller) CheckEmailReminder()

func (*Controller) DestroySession

func (controller *Controller) DestroySession(w http.ResponseWriter, r *http.Request)

DestroySession destroys a user's session by setting a negative maximum age

func (*Controller) GetLoginRedirect

func (controller *Controller) GetLoginRedirect(r *http.Request) string

GetLoginRedirect retrieves the previously set path for redirection after login

func (*Controller) GetUser

func (controller *Controller) GetUser(r *http.Request) (*models.User, error)

GetUser returns the user-object stored in the data session

func (*Controller) IsLoggedIn

func (controller *Controller) IsLoggedIn(w http.ResponseWriter, r *http.Request) bool

IsLoggedIn checks whether the user is currently logged in and has an appropriate timestamp set

func (*Controller) LoadPOSes

func (controller *Controller) LoadPOSes() ([]*models.POS, error)

func (*Controller) RefreshCache

func (controller *Controller) RefreshCache()

func (*Controller) SendPasswordReset

func (controller *Controller) SendPasswordReset(w http.ResponseWriter, r *http.Request, username string, email string) error

SendPasswordReset sends an email with a verification link to reset a user's password to the given address

func (*Controller) SetLoginRedirect

func (controller *Controller) SetLoginRedirect(w http.ResponseWriter, r *http.Request, redirect string) error

SetLoginRedirect saves the given path as a redirect after successful login

func (*Controller) SetUser

func (controller *Controller) SetUser(w http.ResponseWriter, r *http.Request, user *models.User) (*models.User, error)

SetUser saves the given user object to the database and updates the data session reference

func (*Controller) StartEmailReminderTicker

func (controller *Controller) StartEmailReminderTicker()

func (*Controller) StartRefreshTimer

func (controller *Controller) StartRefreshTimer()

func (*Controller) VerifyPasswordReset

func (controller *Controller) VerifyPasswordReset(w http.ResponseWriter, r *http.Request, email string, username string, verification string, password string) error

Jump to

Keyboard shortcuts

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