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 ¶
- type Controller
- func (controller *Controller) Authenticate(w http.ResponseWriter, r *http.Request, username string, password string) error
- func (controller *Controller) CalculateFuelShoppingList(poses []*models.POS) (*models.FuelShoppingList, error)
- func (controller *Controller) CheckEmailReminder()
- func (controller *Controller) DestroySession(w http.ResponseWriter, r *http.Request)
- func (controller *Controller) GetLoginRedirect(r *http.Request) string
- func (controller *Controller) GetUser(r *http.Request) (*models.User, error)
- func (controller *Controller) IsLoggedIn(w http.ResponseWriter, r *http.Request) bool
- func (controller *Controller) LoadPOSes() ([]*models.POS, error)
- func (controller *Controller) RefreshCache()
- func (controller *Controller) SendPasswordReset(w http.ResponseWriter, r *http.Request, username string, email string) error
- func (controller *Controller) SetLoginRedirect(w http.ResponseWriter, r *http.Request, redirect string) error
- func (controller *Controller) SetUser(w http.ResponseWriter, r *http.Request, user *models.User) (*models.User, error)
- func (controller *Controller) StartEmailReminderTicker()
- func (controller *Controller) StartRefreshTimer()
- func (controller *Controller) VerifyPasswordReset(w http.ResponseWriter, r *http.Request, email string, username string, ...) error
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) 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) 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