Example #1
0
//GetLocale from request
func GetLocale(request prago.Request) string {
	user, hasUser := request.GetData("currentuser").(*User)
	if hasUser {
		if validLocale(user.Locale) {
			return user.Locale
		}
	}
	return localeFromRequest(request)
}
Example #2
0
//GetUser returns currently logged in user
func GetUser(request prago.Request) *User {
	return request.GetData("currentuser").(*User)
}
Example #3
0
//CSRFToken returns csrf token from request
func CSRFToken(request prago.Request) string {
	return request.GetData("_csrfToken").(string)
}
Example #4
0
//AddFlashMessage adds flash message to request
func AddFlashMessage(request prago.Request, message string) {
	session := request.GetData("session").(*sessions.Session)
	session.AddFlash(message)
	prago.Must(session.Save(request.Request(), request.Response()))
}