class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time
  include ApplicationHelper
  before_filter :check_authorization

  protect_from_forgery  :secret => 'a0eb34fe2f95d34c9b4035eb8c3cabde'
  
   # Wybierz unikatow nazw pliku cookie, aby odrni dane naszej sesji spord innych
  session :session_key => '_rails_space_session_id'
  
  # Sprawd, czy istnieje poprawny plik cookie, ewentualnie zaloguj uytkownika
  def check_authorization
    authorization_token = cookies[:authorization_token]
    if cookies[:authorization_token] and not logged_in?
      user = User.find_by_authorization_token(authorization_token)
      user.login!(session) if user
    end
  end
end

