Account Controller Hook Question
Added by Michael Locke almost 11 years ago
I have been working on a plug-in to perform some actions after a user successfully authenticates. Using the tutorials I found on the web, I wrote the following:
module Hooks class AuthSuccessHook < Redmine::Hook::Listener def controller_account_success_authentication_after(context) ... end end end
I add my hook file (hooks/auth_success_hook) to my init.rb file and restart my server. After authenticating successfully, I get a 500 Internal Server Error page. Opening the log file, I see the following error:
Completed 500 Internal Server Error in 413ms ArgumentError (wrong number of arguments (1 for 0)): lib/redmine/hook.rb:61:in `send' lib/redmine/hook.rb:61:in `call_hook' lib/redmine/hook.rb:61:in `each' lib/redmine/hook.rb:61:in `call_hook' lib/redmine/hook.rb:58:in `tap' lib/redmine/hook.rb:58:in `call_hook' lib/redmine/hook.rb:153:in `call_hook' app/controllers/account_controller.rb:229:in `successful_authentication' app/controllers/account_controller.rb:174:in `password_authentication' app/controllers/account_controller.rb:161:in `authenticate_user' app/controllers/account_controller.rb:32:in `login'
This error tells me that I did not declare a method argument in my hook file. But as you can clearly see, I do have an argument to my function. Just to prove it is not a fluke, if I change the method declaration line to this:
def controller_account_success_authentication_after(context, params)
The following error is returned:
Completed 500 Internal Server Error in 505ms ArgumentError (wrong number of arguments (1 for 2)): lib/redmine/hook.rb:61:in `controller_account_success_authentication_after' lib/redmine/hook.rb:61:in `send' lib/redmine/hook.rb:61:in `call_hook' lib/redmine/hook.rb:61:in `each' lib/redmine/hook.rb:61:in `call_hook' lib/redmine/hook.rb:58:in `tap' lib/redmine/hook.rb:58:in `call_hook' lib/redmine/hook.rb:153:in `call_hook' app/controllers/account_controller.rb:229:in `successful_authentication' app/controllers/account_controller.rb:174:in `password_authentication' app/controllers/account_controller.rb:161:in `authenticate_user' app/controllers/account_controller.rb:32:in `login'
So I am confused. I am not sure if this is an issue with Redmine, Ruby or Rails. Current versions in place:
Redmine: 2.3.1
Ruby: 1.8.7
Rails: 3.2.13
Any help would be appreciated.