// SetCurrentUser is a middleware which adds current_user info to
// the incoming request
SetCurrentUser is a middleware which adds current_user info to
the incoming request
// SetCurrentUser is a middleware which adds current_user info to // the incoming request
func SetCurrentUser(next buffalo.Handler) buffalo.Handler {
	return func(c buffalo.Context) error {
		if uid := c.Session().Get("current_user_id"); uid != nil {
			u := &models.User{}
			tx := c.Value("tx").(*pop.Connection)
			if err := tx.Find(u, uid); err != nil {
				return errors.WithStack(err)
			}
			c.Set("current_user", u)
		}
		return next(c)
	}
}
func SetCurrentUser ( next buffalo . Handler ) buffalo . Handler { return func ( c buffalo . Context ) error { if uid := c . Session ( ) . Get ( " " ) ; uid != nil { u := & models . User { } tx := c . Value ( " " ) . ( * pop . Connection ) if err := tx . Find ( u , uid ) ; err != nil { return errors . WithStack ( err ) } c . Set ( " " , u ) } return next ( c ) } }
SetCurrentUser is a middleware which adds current_user info to
the incoming request
SetCurrentUser is a middleware which adds current_user info to the incoming request