Post authentication action (using hooks?)
Added by Anthony Paul over 14 years ago
Hi all,
I'm sorry to come back again with a hook problem. I saw many topics about it, but I'm still stuck...
I would like (in a plugin) to run some code after the user authentication. By now, I'm interested in 2 things:
1- I'd like to check if that authenticated user is a member of a specific project (and if he isn't, so I'd add him)
2- I'd also like to check if the user is part of some LDAP group (so I would avoid to modify the LDAP filter which is inside Redmine core)
I saw there is a hook named :controller_account_success_authentication_after. Sounds nice, but I don't know how to use it, even I looked in different messages on this forum such like http://www.redmine.org/issues/1677 or in well-known plugins (http://github.com/edavis10/redmine-budget-plugin/tree/master).
As soon as I add something like:
# init.rb: add_hook(:controller_account_success_authentication_after, Proc.new{MyPlugin.test})
and
# lib/my_plugin.rb class MyPlugin < Redmine::Plugin::Hook::Base def self.test return flash[:error]= "test" end end
Rails tells me "undefined method `add_hook'" (so it doesn't even have a look in lib/my_plugin.rb)
I can't find some "easy to understand" example, especially I don't know if "hooks" would help me to do what I want...
Thanks for any clue or idea...
Replies (1)
RE: Post authentication action (using hooks?) - Added by Felix Schäfer over 14 years ago
I think the hook yould help, but you are using it wrong :-) See if you can get a hold of Eric Davis (edavis10) on IRC, he will be able to help.