1
0
Fork 0

Null session id fix

This commit is contained in:
magnolia-fan 2011-04-13 09:04:13 +04:00
parent 58a34fb3a8
commit 970400cb74
2 changed files with 12 additions and 2 deletions

View File

@ -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 = ''

View File

@ -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