lib/classiccms/controllers/application.rb in classiccms-0.5.2 vs lib/classiccms/controllers/application.rb in classiccms-0.5.5
- old
+ new
@@ -14,10 +14,14 @@
set :session_secret, '427a474a206b616e5c4f2a4f3c7d2d517e2a564e21556e24593363253e'
enable :sessions
before do
- @user = User.find(session[:user_id]) if session[:user_id] != nil
+ if User.where(:_id => session[:user_id]).count > 0
+ @user = User.find(session[:user_id]) if session[:user_id] != nil
+ else
+ session[:user_id] = nil
+ end
end
get '/login' do
show :login, views: File.join(Classiccms::ROOT, 'views/cms')
end