Skip to content

Commit

Permalink
adding after_successful_signup and after_failed_signup callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
zdennis committed Nov 10, 2007
1 parent df74985 commit 068b2a2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/login_controller.rb
Expand Up @@ -46,6 +46,9 @@ def acts_as_login_controller( options = {} )
if lwt_authentication_system_options[:allow_signup]
include LWT::AuthenticationSystem::LoginController::SignupInstanceMethods
end

after_successful_signup do ; end
after_failed_signup do ; end

redirect_after_logout do
{ :action => 'login' }
Expand All @@ -72,7 +75,7 @@ def restrict_to *privileges, &blk

super( *privileges, &blk )
end

# Sets the arguments to be passed to redirect_to after a user
# successfully logs in. The block will be evaluated in the scope
# of the controller.
Expand All @@ -94,6 +97,14 @@ def redirect_after_logout &blk
self.lwt_authentication_system_options[:redirect_after_logout] = blk
end

def after_successful_signup &blk
self.lwt_authentication_system_options[:after_successful_signup] = blk
end

def after_failed_signup &blk
self.lwt_authentication_system_options[:after_failed_signup] = blk
end

# Sets the arguments to be passed to redirect_to after a user
# successfully signs up. The block will be evaluated in the scope
# of the controller.
Expand Down Expand Up @@ -225,7 +236,10 @@ def signup
:from => self.class.lwt_authentication_system_options[:email_from],
:subject => self.class.lwt_authentication_system_options[:signup_email_subject] )
flash[:notice] = self.class.lwt_authentication_system_options[:successful_signup_flash]
instance_eval &self.class.lwt_authentication_system_options[:after_successful_signup]
redirect_to self.instance_eval( &self.class.lwt_authentication_system_options[:redirect_after_signup] )
else
instance_eval &self.class.lwt_authentication_system_options[:after_failed_signup]
end
else
flash[:notice] = self.class.lwt_authentication_system_options[:signup_flash]
Expand Down

0 comments on commit 068b2a2

Please sign in to comment.