From 970400cb744fc8d3d71a1b823392a9289950a2eb Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Wed, 13 Apr 2011 09:04:13 +0400 Subject: [PATCH] Null session id fix --- app/controllers/artist_controller.rb | 6 +++++- app/controllers/main_controller.rb | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/artist_controller.rb b/app/controllers/artist_controller.rb index bddd09c..0e28a08 100644 --- a/app/controllers/artist_controller.rb +++ b/app/controllers/artist_controller.rb @@ -2,8 +2,12 @@ class ArtistController < ApplicationController require 'open-uri' def view - unless MainController.logged_in request.session['session_id'] + unless request.session['session_id'].nil? or MainController.logged_in request.session['session_id'] redirect_to '/login' + else + if request.session['session_id'].nil? + redirect_to '/login' + end end if params[:name].nil? name = '' diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 5a69b89..3e3d473 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -1,8 +1,14 @@ class MainController < ApplicationController def index - unless MainController.logged_in request.session['session_id'] + # Dirty auth block START + unless request.session['session_id'].nil? or MainController.logged_in request.session['session_id'] redirect_to '/login' + else + if request.session['session_id'].nil? + redirect_to '/login' + end end + # Dirty auth block END end def self.logged_in session_id user_data = User.collection.find({session_key: Digest::SHA256.hexdigest(session_id)}).first