Sha256: c9c3221f267256d9f2881100f80ddfa41ea7d7cba5e4936519252148f1d4abf9

Contents?: true

Size: 612 Bytes

Versions: 3

Compression:

Stored size: 612 Bytes

Contents

module Thincloud
  module Auth
    module Controller
      extend ActiveSupport::Concern

      included do
        helper_method :current_user
      end


      private

      def warden
        env["warden"]
      end

      def current_user
        warden.user
      end

      def authorize
        return true if current_user.present?
        session[:return_to] ||= request.url
        redirect_to login_url, alert: "Not authorized"
      end

      def after_login_path
        session.delete(:return_to) || root_path
      end

      def after_logout_path
        login_path
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thincloud-auth-0.1.2 lib/thincloud/auth/controller.rb
thincloud-auth-0.1.1 lib/thincloud/auth/controller.rb
thincloud-auth-0.1.0 lib/thincloud/auth/controller.rb