func SendConfirmAddress(c context.Context, e *Email) (err error) { v, err := config.GetOrInsert(c, "app", defaultConfig) if err != nil { return err } et := token.New(c) et.EmailAddress = e.Address if err = et.Put(c); err != nil { return err } v.Values["VerfyURL"] = genVerifyURL(v.Values["SiteURL"], et.Token) m := &mail.TemplateMessage{} m.Sender = v.Values["SenderAddress"] m.To = []string{e.Address} m.Subject = fmt.Sprintf(v.Values["Subject"], e.Address) m.BodyValues = v.Values m.BodyTmplPath = v.Values["BodyTmplPath"] mail.SendLater.Call(c, m) return nil }
func GetStore(c appengine.Context) (sessions.Store, error) { var initializerError error initializer.Do(func() { storeConfig, err := config.GetOrInsert(c, "SessionKeys", defaultConfig) if err != nil { initializerError = err initializer = new(sync.Once) // We create a new initializer if we error out because instances of sync.Once can not be reset any other way. return } store = sessions.NewCookieStore([]byte(storeConfig.Values["AuthenticationKey"]), []byte(storeConfig.Values["EncryptionKey"])) }) if initializerError != nil { // We've got an error from the initializer. return nil, initializerError } if store == nil { // This more than likely means that store failed to initialize in another goroutine. return nil, UnknownError } return store, nil }