]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/application_controller.rb
Use asset_path to find the arrow icon
[rails.git] / app / controllers / application_controller.rb
index 2d137cc41d7be704914a395899e4067adf1c2f22..f07cacbd6cb121f96a29857781bd795875190f9c 100644 (file)
@@ -3,7 +3,12 @@ class ApplicationController < ActionController::Base
   protect_from_forgery
 
   if STATUS == :database_readonly or STATUS == :database_offline
-    session :off
+    after_filter :clear_session
+    wrap_parameters false
+
+    def clear_session
+      session.clear
+    end
 
     def self.cache_sweeper(*sweepers)
     end
@@ -13,7 +18,10 @@ class ApplicationController < ActionController::Base
     if session[:user]
       @user = User.where(:id => session[:user]).where("status IN ('active', 'confirmed', 'suspended')").first
 
-      if @user.status == "suspended"
+      if @user.display_name != cookies["_osm_username"]
+        reset_session
+        @user = nil
+      elsif @user.status == "suspended"
         session.delete(:user)
         session_expires_automatically
 
@@ -30,11 +38,13 @@ class ApplicationController < ActionController::Base
         end
       end
     elsif session[:token]
-      @user = User.authenticate(:token => session[:token])
-      session[:user] = @user.id
+      if @user = User.authenticate(:token => session[:token])
+        session[:user] = @user.id
+      end
     end
   rescue Exception => ex
     logger.info("Exception authorizing user: #{ex.to_s}")
+    reset_session
     @user = nil
   end