class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time
  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
    if cookies[:authorization_token] and not session[:user_id]
      user = User.find_by_authorization_token (cookies[:authorization_token])
      if user
        session[:user_id] = user.id
      end
    end
  end
end

