Sha256: 2b47fc2427c395929867398824fbdb35914a6ee805fd4ada4f70acdaeea2183f

Contents?: true

Size: 1.34 KB

Versions: 14

Compression:

Stored size: 1.34 KB

Contents

module Castronaut
  module Presenters

    class Logout
      attr_reader :controller, :your_mission
      attr_accessor :messages

      delegate :params, :request, :to => :controller
      delegate :cookies, :env, :to => :request

      def initialize(controller)
        @controller = controller
        @messages = []
        @your_mission = nil
      end

      def url
        params['url']
      end

      def ticket_granting_ticket_cookie
        cookies['tgt']
      end

      def client_host
        env['HTTP_X_FORWARDED_FOR'] || env['REMOTE_HOST'] || env['REMOTE_ADDR']
      end
      
      def login_ticket
        Castronaut::Models::LoginTicket.generate_from(client_host).ticket
      end

      def represent!
        ticket_granting_ticket = Castronaut::Models::TicketGrantingTicket.find_by_ticket(ticket_granting_ticket_cookie) 
        
        cookies.delete 'tgt'
        controller.delete_cookie('tgt')

        if ticket_granting_ticket
          Castronaut::Models::ProxyGrantingTicket.clean_up_proxy_granting_tickets_for(ticket_granting_ticket.username)
          ticket_granting_ticket.destroy
        end
        
        messages << "You have successfully logged out."
        
        @your_mission = lambda { controller.erb :logout, :locals => { :presenter => self } }
                
        self
      end
    
    end

  end
  
end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
masover-castronaut-0.4.4.4 lib/castronaut/presenters/logout.rb
p8-castronaut-0.6.1.1 lib/castronaut/presenters/logout.rb
relevance-castronaut-0.4.2 lib/castronaut/presenters/logout.rb
relevance-castronaut-0.4.3 lib/castronaut/presenters/logout.rb
relevance-castronaut-0.4.4 lib/castronaut/presenters/logout.rb
relevance-castronaut-0.4.5 lib/castronaut/presenters/logout.rb
relevance-castronaut-0.4.6 lib/castronaut/presenters/logout.rb
relevance-castronaut-0.5.0 lib/castronaut/presenters/logout.rb
relevance-castronaut-0.5.1 lib/castronaut/presenters/logout.rb
relevance-castronaut-0.5.2 lib/castronaut/presenters/logout.rb
relevance-castronaut-0.5.3 lib/castronaut/presenters/logout.rb
relevance-castronaut-0.5.4 lib/castronaut/presenters/logout.rb
relevance-castronaut-0.6.0 lib/castronaut/presenters/logout.rb
relevance-castronaut-0.6.1 lib/castronaut/presenters/logout.rb