Documentation
¶
Index ¶
- Constants
- func CreateSession(username string) models.Session
- func CreateSessionToken() string
- func GetCurrentAccountFromSession(db database.Database, logger log.Logger, sesh models.Session) (models.Account, error)
- func GetCurrentSession(db database.Database, logger log.Logger, r *http.Request) (models.Session, error)
- func GetSaltedPassword(password string, salt string) (string, error)
- func Login(db database.Database, username, password string) (models.Session, error)
- func SaltPassword(password string) (string, string, error)
- func SetCookie(w http.ResponseWriter, name, token string, rememberMe bool)
Constants ¶
View Source
const SessionCookieName = "HacksiteSession"
SessionCookieName is the name of the cookie
View Source
const SessionMaxAge = 900
SessionMaxAge is the cookie length in seconds
View Source
const SessionOfOneThousandYears = 31536000000
SessionMaxAge when RememberMe is true... 1000 years in seconds
View Source
const (
// UnathorizedErrorMessage is used to determine if the error is because of unathorized account
UnathorizedErrorMessage = "Account is invalid"
)
Variables ¶
This section is empty.
Functions ¶
func CreateSession ¶
CreateSession returns the session token to store in the cookie
func CreateSessionToken ¶
func CreateSessionToken() string
CreateSessionToken generates a random session token
func GetCurrentAccountFromSession ¶
func GetCurrentAccountFromSession(db database.Database, logger log.Logger, sesh models.Session) (models.Account, error)
GetCurrentAccountFromSession gets the account information for the session
func GetCurrentSession ¶
func GetCurrentSession(db database.Database, logger log.Logger, r *http.Request) (models.Session, error)
GetCurrentSession reads the session cookie and grabs the session associated
func GetSaltedPassword ¶
GetSaltedPassword returns the salted version of the password using the account's salt
func SaltPassword ¶
SaltPassword generates a salt, puts it into the password and returns the salt and the new password or an error
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.