X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/c485ae32490ccf98dcbea96af6218b25540f5eaa..7b89dc63496de0b6131a93c57d283ebb4490804b:/app/controllers/application_controller.rb?ds=inline diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d58bc8922..44307d482 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -18,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 @@ -41,6 +44,7 @@ class ApplicationController < ActionController::Base end rescue Exception => ex logger.info("Exception authorizing user: #{ex.to_s}") + reset_session @user = nil end @@ -243,7 +247,7 @@ class ApplicationController < ActionController::Base end end - I18n.locale = request.compatible_language_from(I18n.available_locales) + I18n.locale = request.compatible_language_from(I18n.available_locales) || I18n.default_locale response.headers['Content-Language'] = I18n.locale.to_s end @@ -362,6 +366,11 @@ private return [user, pass] end + # used by oauth plugin to get the current user + def current_user + @user + end + # used by oauth plugin to set the current user def current_user=(user) @user=user