Exemple #1
0
func authRedirect(res *wcg.Response, req *wcg.Request) {
	ref, _ := req.Session.Get(SESSION_KEY_LOGIN_REF)
	if ref != "" && strings.HasPrefix(ref, "/") {
		res.Redirect(wcg.AbsoluteUrl(req, ref), http.StatusFound)
	} else {
		res.Redirect("/", http.StatusFound)
	}
}
Exemple #2
0
func createPostHandler(res *wcg.Response, req *wcg.Request) {
	blog, _, err := fetchBlogForUpdate(res, req, false)
	if err != nil {
		return
	}
	post := models.NewPost(req.User.Id(), blog.Id)
	err = models.NewPostDriver(gae.NewContext(req), req.Logger).SavePost(post)
	if err != nil {
		res.RenderInternalError(err.Error())
		return
	}
	res.Redirect(fmt.Sprintf("/admin/blogs/%s/%s/", blog.Id, post.Id), http.StatusSeeOther)
}
Exemple #3
0
func Redirect(res *wcg.Response, req *wcg.Request) {
	urlStr := req.Query("u")
	if urlobj, err := url.Parse(urlStr); err == nil && validateUrl(urlobj) {
		// TODO: Check blacklist
		res.Redirect(urlStr, 302)
		return
	}
	res.TemplatesWithStatus(
		404,
		nil,
		"404.html", "header.html", "footer.html",
	)
	return
}
Exemple #4
0
func authorized(res *wcg.Response, req *wcg.Request) {
	res.Redirect("/", http.StatusFound)
}