Documentation ¶
Index ¶
- Constants
- func AppHostname(c *Context) string
- func AppHostnameForPayPal(c *Context) string
- func Assert(condition bool, v ...interface{})
- func CheckError(err error)
- func ConsumeFlash(w http.ResponseWriter, r *http.Request) (string, error)
- func ContainsString(slice []string, str string) bool
- func DeleteCookie(name string, w http.ResponseWriter) error
- func DeleteSession(w http.ResponseWriter, c *Context) error
- func ExecuteTemplate(name string, data interface{}) (template.HTML, error)
- func ExecuteTextTemplate(name string, data interface{}) (string, error)
- func GenerateSecureRandomString() []byte
- func GetCookie(name string, r *http.Request, dst interface{}) error
- func GetPayeeUserKey(reqCode string) *datastore.Key
- func GetUserId(email string, c *Context) (int64, error)
- func GetUserIdOrDie(email string, c *Context) int64
- func GoogleMakeConfig(tokenCache oauth.Cache) *oauth.Config
- func MakeSession(userId int64, email, fullName string, w http.ResponseWriter, c *Context) error
- func NewEphemeralKey(c appengine.Context, kind string) *datastore.Key
- func ParseAmount(amount string) float32
- func ParseEmail(email string) string
- func ParseFullName(fullName string) string
- func ParsePaymentType(paymentTypeStr string) int
- func ReadSession(r *http.Request, c *Context) error
- func RedirectWithMessage(w http.ResponseWriter, r *http.Request, url, msg string)
- func RenderPageOrDie(w http.ResponseWriter, c *Context, name string, data interface{})
- func RenderTemplateOrDie(w http.ResponseWriter, name string, data interface{})
- func SaltAndHash(salt []byte, password string) []byte
- func Serve404(w http.ResponseWriter)
- func ServeError(w http.ResponseWriter, data interface{})
- func ServeInfo(w http.ResponseWriter, info string)
- func SetCookie(name string, value interface{}, options *CookieOptions, w http.ResponseWriter) error
- func SetFlash(value string, w http.ResponseWriter) error
- func ToOAuthTokenKey(c appengine.Context, userId int64, service string) *datastore.Key
- func ToUserIdKey(c appengine.Context, email string) *datastore.Key
- func ToUserKey(c appengine.Context, userId int64) *datastore.Key
- func UpdateSession(s *Session, w http.ResponseWriter, c *Context) error
- func WrapHandler(fn AppHandlerFunc) http.HandlerFunc
- func WrapHandlerImpl(fn AppHandlerFunc, parseForm bool) http.HandlerFunc
- func WrapHandlerNoParseForm(fn AppHandlerFunc) http.HandlerFunc
- type AppHandlerFunc
- type Contact
- type Context
- func (c *Context) Aec() appengine.Context
- func (c *Context) AssertLoggedIn()
- func (c *Context) AssertNotLoggedIn()
- func (c *Context) Delete(key interface{})
- func (c *Context) DeleteSession()
- func (c *Context) Flash() string
- func (c *Context) Get(key interface{}) interface{}
- func (c *Context) LoggedIn() bool
- func (c *Context) Session() *Session
- func (c *Context) Set(key interface{}, value interface{})
- func (c *Context) SetAec(aec appengine.Context)
- func (c *Context) SetFlash(flash string)
- func (c *Context) SetSession(s *Session)
- type CookieOptions
- type DatastoreOAuthTokenCache
- type OAuthToken
- type PageData
- type PayPalIpnMessage
- type PayPalPayResponse
- type PayRequest
- type RenderablePayRequest
- type ResetPassword
- type Session
- type User
- func GetUserFromEmail(email string, c *Context) (int64, *User, error)
- func GetUserFromEmailOrDie(email string, c *Context) (int64, *User)
- func GetUserFromSessionOrDie(c *Context) *User
- func GetUserFromUserId(userId int64, c *Context) (*User, error)
- func GetUserFromUserIdOrDie(userId int64, c *Context) *User
- func GetUserOrDie(key *datastore.Key, c *Context) *User
- type UserId
- type VerifyEmail
Constants ¶
const ( PTPersonal PTGoods PTServices )
Payment types.
const ( SCOPE = "https://www.googleapis.com/auth/userinfo.profile https://www.google.com/m8/feeds" AUTH_URL = "https://accounts.google.com/o/oauth2/auth" TOKEN_URL = "https://accounts.google.com/o/oauth2/token" GOOGLE_API_REQUEST = "https://www.google.com/m8/feeds/contacts/default/full?max-results=10000&alt=json" )
Variables ¶
This section is empty.
Functions ¶
func AppHostname ¶
func AppHostnameForPayPal ¶
func CheckError ¶
func CheckError(err error)
func ConsumeFlash ¶
Returns http.ErrNoCookie if there is no flash message.
func ContainsString ¶
func DeleteCookie ¶
func DeleteCookie(name string, w http.ResponseWriter) error
func DeleteSession ¶
func DeleteSession(w http.ResponseWriter, c *Context) error
Deletes session cookie (if any) and updates context.
func ExecuteTemplate ¶
If the returned error is not nil, it is guaranteed to have type template.Error.
func ExecuteTextTemplate ¶
func GenerateSecureRandomString ¶
func GenerateSecureRandomString() []byte
func GetCookie ¶
Reads cookie value into dst. Returns http.ErrNoCookie if there is no cookie with the given name.
func GetPayeeUserKey ¶
func GetUserIdOrDie ¶
func GoogleMakeConfig ¶
NOTE(sadovsky): We set ApprovalPrompt to "force" so that we can easily recover from losing a refresh token.
func MakeSession ¶
Sets session cookie and updates context.
func ParseAmount ¶
func ParseEmail ¶
func ParseFullName ¶
func ParsePaymentType ¶
func ReadSession ¶
Reads session cookie and updates context.
func RedirectWithMessage ¶
func RedirectWithMessage(w http.ResponseWriter, r *http.Request, url, msg string)
func RenderPageOrDie ¶
func RenderPageOrDie(w http.ResponseWriter, c *Context, name string, data interface{})
func RenderTemplateOrDie ¶
func RenderTemplateOrDie(w http.ResponseWriter, name string, data interface{})
func SaltAndHash ¶
func Serve404 ¶
func Serve404(w http.ResponseWriter)
func ServeError ¶
func ServeError(w http.ResponseWriter, data interface{})
func ServeInfo ¶
func ServeInfo(w http.ResponseWriter, info string)
func SetCookie ¶
func SetCookie(name string, value interface{}, options *CookieOptions, w http.ResponseWriter) error
func ToOAuthTokenKey ¶
func UpdateSession ¶
func UpdateSession(s *Session, w http.ResponseWriter, c *Context) error
Updates session cookie and context.
func WrapHandler ¶
func WrapHandler(fn AppHandlerFunc) http.HandlerFunc
func WrapHandlerImpl ¶
func WrapHandlerImpl(fn AppHandlerFunc, parseForm bool) http.HandlerFunc
Wraps other http handlers. Creates context object, recovers from panics, etc.
func WrapHandlerNoParseForm ¶
func WrapHandlerNoParseForm(fn AppHandlerFunc) http.HandlerFunc
Types ¶
type AppHandlerFunc ¶
type AppHandlerFunc func(http.ResponseWriter, *http.Request, *Context)
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func (*Context) AssertLoggedIn ¶
func (c *Context) AssertLoggedIn()
func (*Context) AssertNotLoggedIn ¶
func (c *Context) AssertNotLoggedIn()
func (*Context) DeleteSession ¶
func (c *Context) DeleteSession()
func (*Context) SetSession ¶
type CookieOptions ¶
type CookieOptions struct {
MaxAge int
}
Subset of http://golang.org/pkg/net/http/#Cookie.
type DatastoreOAuthTokenCache ¶
Implements oauth.Cache.
func (*DatastoreOAuthTokenCache) DeleteToken ¶
func (tc *DatastoreOAuthTokenCache) DeleteToken() error
type OAuthToken ¶
Keyed by service name (e.g. "google"), with User as parent. Subset of oauth.Token.
func GetOAuthTokenFromUserId ¶
func GetOAuthTokenFromUserId(userId int64, service string, c *Context) (*OAuthToken, error)
type PayPalIpnMessage ¶
type PayPalIpnMessage struct { Status string // status PayerEmail string // sender_email PayeeEmail string // transaction[0].receiver Amount float32 // extracted from transaction[0].amount PayKey string // pay_key }
Stores the useful fields from a single paypal IPN message. IPN reference: http://goo.gl/bIX2Q
func PayPalValidateIpn ¶
func PayPalValidateIpn(requestBody string, c *Context) (*PayPalIpnMessage, error)
IPN handler references: http://goo.gl/bIX2Q and http://goo.gl/F1uej
type PayPalPayResponse ¶
type PayPalPayResponse struct { Ack string // responseEnvelope.ack Build string // responseEnvelope.build CorrelationId string // responseEnvelope.correlationId Timestamp string // responseEnvelope.timestamp PayKey string // payKey }
Stores paypal response to one "Pay" request. Pay API reference: http://goo.gl/D6dUR
func PayPalSendPayRequest ¶
type PayRequest ¶
type PayRequest struct { PayeeEmail string // primary email of payee PayerEmail string // email of payer Amount float32 PaymentType int // PTPersonal, PTGoods, or PTServices Description string CreationDate time.Time IsPaid bool // needed for datastore queries PaymentDate time.Time // unix epoch if not yet paid in full DeletionDate time.Time // unix epoch if not deleted ReminderSentDate time.Time // most recent reminder send date, or unix epoch }
Keyed by int (NewIncompleteKey), with payee User as parent. TODO(sadovsky):
- Add field for currency code (same as in paypal request).
- Maybe add a PaymentStatus struct.
type RenderablePayRequest ¶
type ResetPassword ¶
type ResetPassword struct { UserId int64 // user for which to reset password Timestamp time.Time // when this request was made }
Keyed by secure random number (NewEphemeralKey).
type User ¶
type User struct { Email string // primary email of account holder Salt string // DEPRECATED, use SaltB SaltB []byte PassHash string // DEPRECATED, use PassHashB PassHashB []byte // hash of salted password FullName string // full name of user PayPalEmail string // paypal account email EmailOk bool // true if user has verified their primary email }
Keyed by int (NewIncompleteKey).
func GetUserFromSessionOrDie ¶
func GetUserFromUserIdOrDie ¶
type VerifyEmail ¶
type VerifyEmail struct { UserId int64 // user to verify Timestamp time.Time // when this request was made }
Keyed by secure random number (NewEphemeralKey).