passwordless

package
v0.0.0-...-e3fab14 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2015 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenLength int           = 32
	TtlDuration time.Duration = 20 * time.Minute
)

Variables

View Source
var (
	SUITS             []string          = []string{"club", "diamond", "heart", "spade"}
	RANKS             []string          = []string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "j", "q", "k"}
	DEFAULT_HAND_SIZE                   = 9 //
	GLYPH             map[string]string = map[string]string{
		"s1": "\U0001f0a1", "h1": "\U0001f0b1", "d1": "\U0001f0c1", "c1": "\U0001f0d1",
		"s2": "\U0001f0a2", "h2": "\U0001f0b2", "d2": "\U0001f0c2", "c2": "\U0001f0d2",
		"s3": "\U0001f0a3", "h3": "\U0001f0b3", "d3": "\U0001f0c3", "c3": "\U0001f0d3",
		"s4": "\U0001f0a4", "h4": "\U0001f0b4", "d4": "\U0001f0c4", "c4": "\U0001f0d4",
		"s5": "\U0001f0a5", "h5": "\U0001f0b5", "d5": "\U0001f0c5", "c5": "\U0001f0d5",
		"s6": "\U0001f0a6", "h6": "\U0001f0b6", "d6": "\U0001f0c6", "c6": "\U0001f0d6",
		"s7": "\U0001f0a7", "h7": "\U0001f0b7", "d7": "\U0001f0c7", "c7": "\U0001f0d7",
		"s8": "\U0001f0a8", "h8": "\U0001f0b8", "d8": "\U0001f0c8", "c8": "\U0001f0d8",
		"s9": "\U0001f0a9", "h9": "\U0001f0b9", "d9": "\U0001f0c9", "c9": "\U0001f0d9",
		"s10": "\U0001f0aa", "h10": "\U0001f0ba", "d10": "\U0001f0ca", "c10": "\U0001f0da",
		"sj": "\U0001f0ab", "hj": "\U0001f0bb", "dj": "\U0001f0cb", "cj": "\U0001f0db",
		"sq": "\U0001f0ad", "hq": "\U0001f0bd", "dq": "\U0001f0cd", "cq": "\U0001f0dd",
		"sk": "\U0001f0ae", "hk": "\U0001f0be", "dk": "\U0001f0ce", "ck": "\U0001f0de",
	}
)

Functions

func BuildRoutes

func BuildRoutes() http.Handler

BuildRoutes returns the routes for the application.

func CsrfMiddleware

func CsrfMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

CsrfMiddleware adds CSRF support via nosurf.

func GameHandler

func GameHandler(w http.ResponseWriter, r *http.Request)

func GetSession

func GetSession(r *http.Request) *sessions.Session

GetSession returns the session for the site.

func HomeHandler

func HomeHandler(w http.ResponseWriter, r *http.Request)

func IsLoggedIn

func IsLoggedIn(r *http.Request) bool

IsLoggedIn is a convenience function for checking if a User exists in the request context.

func Login

func Login(u *User, w http.ResponseWriter, r *http.Request)

Login adds the User's id to the session.

func LoginRequiredMiddleware

func LoginRequiredMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

LoginRequiredMiddleware ensures a User is logged in, otherwise redirects them to the login page.

func LoginSuccessHandler

func LoginSuccessHandler(w http.ResponseWriter, r *http.Request)

func Logout

func Logout(w http.ResponseWriter, r *http.Request)

Logout removes the User from their session.

func LogoutHandler

func LogoutHandler(w http.ResponseWriter, r *http.Request)

func ProfileHandler

func ProfileHandler(w http.ResponseWriter, r *http.Request)

func SendMail

func SendMail(to []string, subject, message string) error

func SetContextUser

func SetContextUser(user *User, r *http.Request)

SetContextUser stores the given user in the request context.

func UserMiddleware

func UserMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

UserMiddleware checks for the User in the session and adds them to the request context if they exist.

func VerifyHandler

func VerifyHandler(w http.ResponseWriter, r *http.Request)

Types

type Card

type Card struct {
	Suit       string
	Rank       string
	SuitSymbol string
	RankSymbol string
}

func (*Card) RankValue

func (c *Card) RankValue() int

func (*Card) SuitValue

func (c *Card) SuitValue() int

func (*Card) Symbol

func (c *Card) Symbol() string

func (*Card) ToString

func (c *Card) ToString() string

type Deck

type Deck struct {
	Cards []Card
}

Deck

func (*Deck) Hand

func (d *Deck) Hand() Hand

func (*Deck) Shuffle

func (d *Deck) Shuffle() *Deck

func (*Deck) ToString

func (d *Deck) ToString() string

type Hand

type Hand struct {
	Name  string
	Cards []Card
}

func (*Hand) Deal

func (h *Hand) Deal() Card

func (*Hand) ToString

func (h *Hand) ToString() string

type User

type User struct {
	Id        int64       `db:"id"`
	Email     string      `db:"email"`
	Token     string      `db:"token"`
	Ttl       time.Time   `db:"ttl"`
	OriginUrl null.String `db:"originurl"`
}

func GetContextUser

func GetContextUser(r *http.Request) *User

GetContextUser returns the User for the given request context or nil.

func (*User) IsValidToken

func (u *User) IsValidToken(token string) bool

IsValidToken returns a bool indicating that the User's current token hasn't expired and that the provided token is valid.

func (*User) RefreshToken

func (u *User) RefreshToken() error

RefreshToken refreshes Ttl and Token for the User.

func (*User) UpdateOriginUrl

func (u *User) UpdateOriginUrl(originUrl *url.URL) error

Jump to

Keyboard shortcuts

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