示例#1
0
// If redirect is nil, the redirect will go to "/"
func LogoutView(redirect view.URL) view.View {
	return view.RenderView(
		func(context *view.Context, writer *utils.XMLWriter) (err error) {
			Logout(context)
			if redirect != nil {
				return view.Redirect(redirect.URL(context.PathArgs...))
			}
			return view.Redirect("/")
		},
	)
}
示例#2
0
// If redirect is nil, the redirect will go to "/"
func LogoutView(redirect view.URL) view.View {
	return view.RenderView(
		func(ctx *view.Context) (err error) {
			Logout(ctx.Session)
			if redirect != nil {
				return view.Redirect(redirect.URL(ctx))
			}
			return view.Redirect("/")
		},
	)
}
示例#3
0
// EmailIdentity has to be saved after a successful call because the confirmation code could have changed
// confirmationPage needs to be a page with one URL parameter
func (self *EmailIdentity) SendConfirmationEmail(ctx *view.Context, confirmationURL view.URL) <-chan error {
	errChan := make(chan error, 1)

	confirmationCode := self.ConfirmationCode.Get()
	if confirmationCode == "" {
		confirmationCode = bson.NewObjectId().Hex()
		self.ConfirmationCode.SetString(confirmationCode)
	}

	subject := fmt.Sprintf(Config.ConfirmationMessage.EmailSubject, view.Config.SiteName)
	confirm := confirmationURL.URL(ctx) + "?code=" + url.QueryEscape(confirmationCode)
	message := fmt.Sprintf(Config.ConfirmationMessage.EmailMessage, view.Config.SiteName, confirm)

	go func() {
		errChan <- email.NewBriefMessage(subject, message, self.Address.Get()).Send()
		close(errChan)
	}()

	return errChan
}