From 4ac991c2e9e6db04bc571a9c2b3ed5a6226c15cc Mon Sep 17 00:00:00 2001 From: Andriy Lesyuk Date: Tue, 11 Oct 2016 13:54:14 +0300 Subject: [PATCH] Add backward compatibility code for :email_addresses Redmine in Debian stable does not support multiple email addresses yet. So, to support Debian stable's version of Redmine the plugin needs to check if the :email_addresses association is available for User. --- app/controllers/redmine_oauth_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/redmine_oauth_controller.rb b/app/controllers/redmine_oauth_controller.rb index e8fa8ba..1bc3c05 100644 --- a/app/controllers/redmine_oauth_controller.rb +++ b/app/controllers/redmine_oauth_controller.rb @@ -38,7 +38,11 @@ def oauth_google_callback def try_to_login info params[:back_url] = session[:back_url] session.delete(:back_url) - user = User.joins(:email_addresses).where(:email_addresses => { :address => info["email"] }).first_or_create + if User.method_defined?(:email_addresses) + user = User.joins(:email_addresses).where(:email_addresses => { :address => info["email"] }).first_or_create + else + user = User.find_or_initialize_by(:mail => info["email"]) + end if user.new_record? # Self-registration off redirect_to(home_url) && return unless Setting.self_registration?