Closed mvange closed 9 years ago
I see you use 4th rails. I think the problem is in obsolete rails method find_or_initialize_by_mail
.
Not sure if the plugin is supported now but if it is so the code should be reviewed on obsolete methods and replaced on actual analogs.
I´m using ruby 2.1.2p95, Rails 4.2.1 and Redmine 3.0.3 and I made a little change that fixed the problem in my environment. The method find_or_initialize_by_mail is obsolete in rails 4th and the table users was changed for Redmine 3.0.X. Now we have the table email_addresses to store user´s emails.
@ $REDMINE_ROOT/plugins/redmine_omniauth_google
diff --git a/app/controllers/redmine_oauth_controller.rb b/app/controllers/redmine_oauth_controller.rb
index dfb32cf..a0d194c 100644
--- a/app/controllers/redmine_oauth_controller.rb
+++ b/app/controllers/redmine_oauth_controller.rb
@@ -38,7 +38,8 @@ class RedmineOauthController < AccountController
def try_to_login info
params[:back_url] = session[:back_url]
session.delete(:back_url)
- user = User.find_or_initialize_by_mail(info["email"])
+ user = User.joins(:email_addresses).where(:email_addresses => {:address => info["email"]}).first_or_create
if user.new_record?
# Self-registration off
redirect_to(home_url) && return unless Setting.self_registration?
luizduma, thanks for the fix. it solved my problem too.
Hi,
I have configured both google and redmine (bitnami distro) per description. Google set up went well, so passed their test. When I try to log in, either with an account that exists, or with a new one, in order to create account, I get an error 500.
Logs are below.
I'm at a loss. Help!?
Started GET "/oauth_google?back_url=http%3A%2F%2Fbitnami-redmine-4a6c.cloudapp.net%2F" for 70.184.92.15 at 2015-05-07 17:20:28 +0000 Processing by RedmineOauthController#oauth_google as HTML Parameters: {"back_url"=>"http://bitnami-redmine-4a6c.cloudapp.net/"} Current user: anonymous Redirected to https://accounts.google.com/o/oauth2/auth?client_id=359288106455-udlk87jasmbvnpv2r3trbv95p5iaufve.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Fbitnami-redmine-4a6c.cloudapp.net%2Foauth2callback&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile Completed 302 Found in 7ms (ActiveRecord: 0.5ms) Started GET "/oauth2callback?code=4/QR4FYIPE2Di14FE5lPlk8dg6LLMU0PNj-dHM5ajnlL4.QhCHiw76Y5YREnp6UAPFm0FmSclemgI" for 70.184.92.15 at 2015-05-07 17:20:36 +0000 Processing by RedmineOauthController#oauth_google_callback as HTML Parameters: {"code"=>"4/QR4FYIPE2Di14FE5lPlk8dg6LLMU0PNj-dHM5ajnlL4.QhCHiw76Y5YREnp6UAPFm0FmSclemgI"} Current user: anonymous Completed 500 Internal Server Error in 380ms (ActiveRecord: 0.9ms)
NoMethodError (undefined method
find_or_initialize_by_mail' for #<Class:0x007f897ea07788>): activerecord (4.2.1) lib/active_record/dynamic_matchers.rb:26:in
method_missing' plugins/redmine_omniauth_google/app/controllers/redmine_oauth_controller.rb:41:intry_to_login' plugins/redmine_omniauth_google/app/controllers/redmine_oauth_controller.rb:26:in
oauth_google_callback' actionpack (4.2.1) lib/action_controller/metal/implicit_render.rb:4:insend_action' actionpack (4.2.1) lib/abstract_controller/base.rb:198:in
process_action' actionpack (4.2.1) lib/action_controller/metal/rendering.rb:10:inprocess_action' actionpack (4.2.1) lib/abstract_controller/callbacks.rb:20:in
block in process_action' activesupport (4.2.1) lib/active_support/callbacks.rb:117:incall' activesupport (4.2.1) lib/active_support/callbacks.rb:117:in
call' activesupport (4.2.1) lib/active_support/callbacks.rb:555:inblock (2 levels) in compile' activesupport (4.2.1) lib/active_support/callbacks.rb:505:in
call' activesupport (4.2.1) lib/active_support/callbacks.rb:505:incall' activesupport (4.2.1) lib/active_support/callbacks.rb:92:in
_run_callbacks' activesupport (4.2.1) lib/active_support/callbacks.rb:776:in_run_process_action_callbacks' activesupport (4.2.1) lib/active_support/callbacks.rb:81:in
run_callbacks' actionpack (4.2.1) lib/abstract_controller/callbacks.rb:19:inprocess_action' actionpack (4.2.1) lib/action_controller/metal/rescue.rb:29:in
process_action' actionpack (4.2.1) lib/action_controller/metal/instrumentation.rb:32:inblock in process_action' activesupport (4.2.1) lib/active_support/notifications.rb:164:in
block in instrument' activesupport (4.2.1) lib/active_support/notifications/instrumenter.rb:20:ininstrument' activesupport (4.2.1) lib/active_support/notifications.rb:164:in
instrument' actionpack (4.2.1) lib/action_controller/metal/instrumentation.rb:30:inprocess_action' actionpack (4.2.1) lib/action_controller/metal/params_wrapper.rb:250:in
process_action' activerecord (4.2.1) lib/active_record/railties/controller_runtime.rb:18:inprocess_action' actionpack (4.2.1) lib/abstract_controller/base.rb:137:in
process' actionview (4.2.1) lib/action_view/rendering.rb:30:inprocess' actionpack (4.2.1) lib/action_controller/metal.rb:196:in
dispatch' actionpack (4.2.1) lib/action_controller/metal/rack_delegation.rb:13:indispatch' actionpack (4.2.1) lib/action_controller/metal.rb:237:in
block in action'