diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 39fb1ba48f..3328252982 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -273,14 +273,7 @@ class AccountController < ApplicationController end call_hook(:controller_account_success_authentication_after, {:user => user }) - if user.first_login - user.update_attribute(:first_login, false) - - redirect_to :controller => "/my", :action => "first_login", :back_url => params[:back_url] - else - - redirect_back_or_default :controller => '/my', :action => 'page' - end + redirect_according_to_first_login(user) end def set_autologin_cookie(user) @@ -386,7 +379,7 @@ class AccountController < ApplicationController if user.save self.logged_user = user flash[:notice] = l(:notice_account_activated) - redirect_to :controller => '/my', :action => 'account' + redirect_according_to_first_login(user) else yield if block_given? end @@ -412,4 +405,13 @@ class AccountController < ApplicationController flash[:notice] = l(:notice_account_pending) redirect_to :action => 'login' end + + def redirect_according_to_first_login(user) + if user.first_login + user.update_attribute(:first_login, false) + redirect_to :controller => "/my", :action => "first_login", :back_url => params[:back_url] + else + redirect_back_or_default :controller => '/my', :action => 'page' + end + end end