Documentation ¶
Index ¶
- Constants
- type GoLogin
- func (gl *GoLogin) IsLoggedIn(r *http.Request) bool
- func (gl *GoLogin) LoginUser(user User, w http.ResponseWriter, r *http.Request) error
- func (gl *GoLogin) LogoutUser(w http.ResponseWriter, r *http.Request) error
- func (gl *GoLogin) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- type User
Constants ¶
View Source
const ( SESSION_NAME = "user" // gorilla sessions session name SV_USERID = "userid" // stored user id (string) SV_LOGGEDIN = "loggedin" // logged in status (bool) )
session cookie variable names
View Source
const (
CV_CURRENTUSER = "currentuser" // currently logged-in user (User)
)
request context variable names
View Source
const VERSION = "0.1.0"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GoLogin ¶
type GoLogin struct { CookieStore *sessions.CookieStore LoadUser func(userid string) User PermissionDeniedHandler http.HandlerFunc }
func (*GoLogin) IsLoggedIn ¶
Check if the user for this request is logged in
func (*GoLogin) LoginUser ¶
Log the user in
This stores data in a session cookie. The request context's "currentuser" variable is set to the user object that is passed.
func (*GoLogin) LogoutUser ¶
func (*GoLogin) ServeHTTP ¶
func (gl *GoLogin) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
HTTP middleware function
This sets the request context's "currentuser" variable to the user object returned by LoadUser().
Click to show internal directories.
Click to hide internal directories.