Sha256: ae7f9c807b0a39f14615df742e430e623080f1b95fbbeb20e8391839cf450a36

Contents?: true

Size: 546 Bytes

Versions: 2

Compression:

Stored size: 546 Bytes

Contents

# encoding: UTF-8

module Spontaneous
  module Rack
    module UserHelpers

      def unauthorised!
        halt 401#, "You do not have the necessary permissions to update the '#{name}' field"
      end

      def api_key
        request.cookies[AUTH_COOKIE]
      end

      def user
        @user ||= load_user
      end

      def load_user
        env[ACTIVE_USER]
      end

      def show_login_page(locals = {})
        halt(401, erb(:login, :views => Spontaneous.application_dir('/views'), :locals => locals))
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spontaneous-0.2.0.alpha2 lib/spontaneous/rack/user_helpers.rb
spontaneous-0.2.0.alpha1 lib/spontaneous/rack/user_helpers.rb